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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 6 replies
  • 13382 views
  • 3 likes
  • 3 in conversation