?
Solved

calculating values from multiple tables to create one table in SAS

Posted on 2014-11-14
1
Medium Priority
?
208 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 2000 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

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

764 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