DATA Step, Macro, Functions and more

proc tabulate sorting one class descending and the other ascending

Accepted Solution Solved
Reply
Regular Contributor
Posts: 201
Accepted Solution

proc tabulate sorting one class descending and the other ascending

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?


Accepted Solutions
Solution
‎02-15-2018 11:30 AM
Super User
Posts: 13,008

Re: proc tabulate sorting one class descending and the other ascending

Posted in reply to csetzkorn

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


All Replies
SAS Super FREQ
Posts: 9,254

Re: proc tabulate sorting one class descending and the other ascending

Posted in reply to csetzkorn
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
Regular Contributor
Posts: 201

Re: proc tabulate sorting one class descending and the other ascending

Posted in reply to Cynthia_sas
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
SAS Super FREQ
Posts: 9,254

Re: proc tabulate sorting one class descending and the other ascending

Posted in reply to csetzkorn
Hi, sorry, somehow I missed the sentence under the slide.
You only need to use 2 CLASS statements, as @ballardw shows.
cynthia
Solution
‎02-15-2018 11:30 AM
Super User
Posts: 13,008

Re: proc tabulate sorting one class descending and the other ascending

Posted in reply to csetzkorn

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;

Regular Contributor
Posts: 201

Re: proc tabulate sorting one class descending and the other ascending

Amazing did not know you can have separate class statements!
Super User
Posts: 13,008

Re: proc tabulate sorting one class descending and the other ascending

Posted in reply to csetzkorn

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.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 99 views
  • 2 likes
  • 3 in conversation