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-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!

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
  • 12823 views
  • 3 likes
  • 3 in conversation