BookmarkSubscribeRSS Feed
SM8
Obsidian | Level 7 SM8
Obsidian | Level 7

So, 

I have two tables that I created using proc sql and then transposed.

 

Here is the code:

 

proc sql;
create table summary as
select count(distinct key) as vistcnt, state,
date, codes, sum(disbursmnt) as paymnt
from meds
where state in ('NY','PA','NJ')
group by state, date, codes;
quit;

proc sort data = summary;
by state codes;
run;

proc transpose data = summary out=visits prefix=visitcount;
var vistcnt; id date; by state codes;
run;

proc transpose data = summary out=payments prefix=dollars;
var paymnt; id date; by state codes;
run;

 

How can I put these two together and do a summary for the total of vistcnt and paymnt?

2 REPLIES 2
Kurt_Bremser
Super User

Summarize before you transpose. Long datasets are always easier for processing than wide ones.

For detailed help, provide the untransposed dataset in a data step with datalines.

SM8
Obsidian | Level 7 SM8
Obsidian | Level 7

Here is the code before the transpose:

proc sql;
create table summary as
select count(distinct key) as vistcnt, state,
date, codes, sum(disbursmnt) as paymnt
from meds
where state in ('NY','PA','NJ')
group by state, date, codes;
quit;

proc sort data = summary;
by state codes;
run;

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 378 views
  • 0 likes
  • 2 in conversation