Solved

calculating values from multiple tables to create one table in SAS

Posted on 2014-11-14
1
180 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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
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…

759 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now