BookmarkSubscribeRSS Feed
deleted_user
Not applicable
I created a summary table, with numerous classification variable on the left hand side of the table. Additionally, I have numerous analysis variables as well on the top. SAS currently sorts or lists the table by order of the classification variable. I would like to sort the the table by one of the analysis variable (descending order). Any ideas as to how to do this.

Thanks,
2 REPLIES 2
deleted_user
Not applicable
I have a nagging feeling that I may be missing something here but why not just use PROC SORT. It will sort any dataset by any variable in either order. If that wasn't what you were looking for perhaps you could elaborate.

Regards,
Jim Lane
Cynthia_sas
SAS Super FREQ
It's also possible that the task being used to generate the table has an ORDER= option embedded in the code and that ORDER= option needs to change. Looking at the code generated from the task should clarify what's going on.

In some instances, doing a SORT -before- the task can work with the ORDER= option -- it really depends on the procedure being used and the desired outcome.

If I'm understanding the question, however, it sounds like there are class variables going down the rows and sum or count of the analysis variables going across the columns of the SUMMARY table:
[pre]
clvar var1 var2 var3
aaa 100 200 300
bbb 400 200 300
ccc 101 100 99
[/pre]

Something like the summary table above. The problem I see with showing the analysis variables in DESCENDING order going across the columns, is that for row 'aaa' the VAR3 value would be in the first column, but for row 'bbb', VAR1 value would be in the first column and for row 'ccc', the VAR1 column would be the first one, etc, etc. Every row's order in the summary table would be based on different variables. Unless you have very regular data, it seems like this is the most likely case.

Most SAS procedures would expect to ALWAYS have the sum of the VAR1 values showing in the first column of the above report table. The variables going across the table as columns, in the above instance, represent the sum of all the VAR1 values, all the VAR2 values, all the VAR3 values -- they're not arbitrary columns, they are linked to their respective variables.

Ordering on the classification variables makes the most sense for the above table given the meaning of the variables going across the top of the table.

If you really wanted to order each row's summary values for VAR1, VAR2 and VAR3 independently of each other, you could create an output dataset from the summary table task and then manipulate that output data, so that you created NEWORD1, NEWORD2, NEWORD3 and then for every row, your program would put the highest value for the row in NEWORD1, the next highest value in NEWORD2 and the next highest value in NEWORD3, etc, etc.

I think you could probably do it with a couple of PROC TRANSPOSE steps and a sort or in Data step processing.

cynthia

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 1796 views
  • 0 likes
  • 2 in conversation