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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.