Solved

calculating values from multiple tables to create one table in SAS

Posted on 2014-11-14
1
193 Views
Last Modified: 2016-02-13
Experts,

I was wondering if there was a way to get the totals from multiple tables and put the values in one table.

Example:  I want to count the distinct row_nums from each table as in the statements below and have the results in one table.

Select COUNT(distinct row_num) AS TOTAL_HIP_MEDICAID from ALL_CLAIMS;
Select COUNT(distinct row_num) AS TOTAL_MATCHED_CLAIMS from MATCHED_CLAIMS;
Select COUNT(distinct row_num) AS NOT_MATCHED_CLAIMS from NOT_MATCHED;
0
Comment
Question by:morinia
1 Comment
 
LVL 14

Accepted Solution

by:
Aloysius Low earned 500 total points
ID: 40444103
if you need them all in 1 column:
Select COUNT(distinct row_num) AS TOTAL, "HIP_MEDICAID" as TYPE from ALL_CLAIMS union all
Select COUNT(distinct row_num) AS TOTAL, "MATCHED_CLAIMS" as TYPE from MATCHED_CLAIMS union all
Select COUNT(distinct row_num) AS TOTAL, "NOT_MATCHED_CLAIMS" as TYPE from NOT_MATCHED;

if you need them in different columns (i.e. 1 row)
Select COUNT(distinct row_num) AS TOTAL_HIP_MEDICAID from ALL_CLAIMS cross join
Select COUNT(distinct row_num) AS TOTAL_MATCHED_CLAIMS from MATCHED_CLAIMS cross join
Select COUNT(distinct row_num) AS NOT_MATCHED_CLAIMS from NOT_MATCHED;

i'm taking a stab in the dark as i do not have an environment to execute the code on.. let me know if there's any errors then we'll work from there
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
understanding output of mysql version 2 65
Fixing Non-Standard characters in text 8 110
Need Distinct Value from Joined Tables in MSSQL 5 64
Trigger usage 2 75
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Creating and Managing Databases with phpMyAdmin in cPanel.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

790 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question