data test;
input desc $;
datalines;
a1
a2
a3
a3
a2
a1
a1
a3
a2
a1
a3
a3
;
run;
proc freq data=test;
tables desc;
run;
Have:
a1 | 4 | 33.33 | 4 | 33.33 |
a2 | 3 | 25.00 | 7 | 58.33 |
a3 | 5 | 41.67 | 12 | 100.00 |
Want:
Summary | ||
a1 | a2 | a3 |
4 | 3 | 5 |
There are going to be ways to do this in one step, but the two-step version is easy to understand:
proc freq data=test;
tables desc / noprint out=counts;
run;
proc tabulate data=counts;
class desc;
var count;
tables count, desc=' '*sum=' ';
title 'Summary';
run;
There are going to be ways to do this in one step, but the two-step version is easy to understand:
proc freq data=test;
tables desc / noprint out=counts;
run;
proc tabulate data=counts;
class desc;
var count;
tables count, desc=' '*sum=' ';
title 'Summary';
run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.