BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
GreggB
Pyrite | Level 9

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
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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;

View solution in original post

5 REPLIES 5
Reeza
Super User

Include the code you're using please. 

 

Have you tried order= option?

GreggB
Pyrite | Level 9

proc freq;
table grade17*exitcode*grade16*exit16/list missing;
run;

ballardw
Super User

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;

BigFluffyTail
Fluorite | Level 6

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;

Rick_SAS
SAS Super FREQ

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."

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 4055 views
  • 1 like
  • 5 in conversation