SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
csetzkorn
Lapis Lazuli | Level 10

It is possible to sort all classes descending:

 

PROC TABULATE DATA=AnalysisData;
   CLASS Y X /descending;
   TABLE Y, X * N;
RUN;

Is it also possible to sort one class descending and the other ascending?

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@csetzkorn wrote:

It is possible to sort all classes descending:

 

PROC TABULATE DATA=AnalysisData;
   CLASS Y X /descending;
   TABLE Y, X * N;
RUN;

Is it also possible to sort one class descending and the other ascending?


Yes but you would use multiple class statements.

Class y /descending;

class x /ascending;

And other orders could be used with the ORDER= option. Again a separate class statement would be used for different values of the option.

class z/ order=freq;

View solution in original post

6 REPLIES 6
Cynthia_sas
SAS Super FREQ
Hi, your message titles asks for one thing (one class variable descending and the other ascending) and your message itself asks for something different (all classes descending). Which do you want? And do you have any data to post? What is all your code, including any ODS statements.
cynthia
csetzkorn
Lapis Lazuli | Level 10
sorry I do not think so - if you read it again (-: I provided an example to show you that I did my homework, which shows sorting all classes but my requirement is to sort them asc and desc
Cynthia_sas
SAS Super FREQ
Hi, sorry, somehow I missed the sentence under the slide.
You only need to use 2 CLASS statements, as @ballardw shows.
cynthia
ballardw
Super User

@csetzkorn wrote:

It is possible to sort all classes descending:

 

PROC TABULATE DATA=AnalysisData;
   CLASS Y X /descending;
   TABLE Y, X * N;
RUN;

Is it also possible to sort one class descending and the other ascending?


Yes but you would use multiple class statements.

Class y /descending;

class x /ascending;

And other orders could be used with the ORDER= option. Again a separate class statement would be used for different values of the option.

class z/ order=freq;

csetzkorn
Lapis Lazuli | Level 10
Amazing did not know you can have separate class statements!
ballardw
Super User

@csetzkorn wrote:
Amazing did not know you can have separate class statements!

 

The you likely will find that you can also have multiple table, classlev and var statements helpful as well.

sas-innovate-white.png

Special offer for SAS Communities members

Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.

 

View the full agenda.

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 14855 views
  • 3 likes
  • 3 in conversation