hi,
Having some issue populating a summary table by date. Specifically, I would like each value under variable STATUS to appear horizontally. Is this possible with PROC FREQ?
Example data:
Data table1;
FORMAT DATE $12. STATUS $2.;
Input DATE STATUS ;
Datalines;
01MAR2017 DU
01MAR2017 DU
01MAR2017 DU
01MAR2017 FI
01MAR2017 FI
01MAR2017 TU
01MAR2017 TU
01MAR2017 Z1
01MAR2017 Z1
02MAR2017 DU
02MAR2017 FI
02MAR2017 TU
02MAR2017 Z1
Run;
Would like output table to look like this:
DATE DU FI TU ZI
01MAR2017 3 2 2 2
02MAR2017 1 1 1 1
Proc Freq code
proc FREQ data=table1 NOPRINT; TABLES Date * Status /norow nocol NOPERCENT OUT=table2; RUN;
Thank you
OK, I think I get what you are asking for now. Continue, adding to your program after the PROC FREQ:
proc transpose data=table2 out=want;
var count;
id status;
by date;
run;
You might need to drop _NAME_ from the result, but the pieces should now align the way you are asking.
How is this basic table different from what you desire?
tables date * status;
thanks, tried that but the column is still listed "STATUS" with each value listed below, by date
Post your code.
i have ...
proc FREQ data=table1 NOPRINT; TABLES Date * Status /norow nocol NOPERCENT OUT=table2; RUN;
Thanks
OK, I think I get what you are asking for now. Continue, adding to your program after the PROC FREQ:
proc transpose data=table2 out=want;
var count;
id status;
by date;
run;
You might need to drop _NAME_ from the result, but the pieces should now align the way you are asking.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.