How can I change the order of the output so that grade17 appears in descending order?
SAS Output
grade17 | exitcode | grade16 | exit16 | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|---|---|---|
0 | . | 574 | 5.72 | 574 | 5.72 | ||
0 | 0 | 213 | 2.12 | 787 | 7.85 | ||
0 | 0 | NS | 1 | 0.01 | 788 | 7.86 | |
1 | . | 44 | 0.44 | 832 | 8.30 | ||
1 | 0 | 731 | 7.29 | 1563 | 15.58 | ||
1 | 0 | GC | 3 | 0.03 | 1566 | 15.61 | |
1 | 0 | NS | 1 | 0.01 | 1567 | 15.62 | |
1 | 0 | W22 | 10 | 0.10 | 1577 | 15.72 | |
1 | 0 | W25 | 1 | 0.01 | 1578 | 15.73 | |
1 | 1 | 12 | 0.12 | 1590 | 15.85 | ||
2 | . | 40 | 0.40 | 1630 | 16.25 |
Easiest may be to send the data to an output data set and sort that.
proc freq noprint ;
table grade17*exitcode*grade16*exit16/list missing out=temp ;
run;
proc sort data=temp;
by descending grade17;
run;
proc print data=temp;
run;
Include the code you're using please.
Have you tried order= option?
proc freq;
table grade17*exitcode*grade16*exit16/list missing;
run;
Easiest may be to send the data to an output data set and sort that.
proc freq noprint ;
table grade17*exitcode*grade16*exit16/list missing out=temp ;
run;
proc sort data=temp;
by descending grade17;
run;
proc print data=temp;
run;
You need to sort the data in descending order by grade17. Then, in the proc freq, use the order=data option.
proc sort data=filename;
by descending grade17;
run;
proc freq data=filename order=data;
table grade17*exitcode*grade16*exit16;
run;
In this case you only needed a sort on one variable. If you ever need to sort by two variables, see the article "How to order categories in a two-way table with PROC FREQ."
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.