Solved

calculating values from multiple tables to create one table in SAS

Posted on 2014-11-14
1
200 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
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…

728 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