Solved

calculating values from multiple tables to create one table in SAS

Posted on 2014-11-14
1
192 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
Preserving formatting after data refresh in a table in Excel 3 81
How To Choose The Right "Big Data" Certification 5 121
use lov values 2 50
How to join on ID, with prefix? 15 58
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Read about achieving the basic levels of HRIS security in the workplace.
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…

770 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