BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
JSJ
Quartz | Level 8 JSJ
Quartz | Level 8

Hi,

 

I would like to put my output from my summary table in a specific order.

 

I created the summary and then output the results to a work file, so I can reorder it. Now it is ordering in alpabetical order.

 

One way I thought of is to create a calculated value based on the row, and then another calculated value with a case to assign my row number to sort--

 

Anyone have a function for row?  Monotonic() returns odd results when I try to add to it!

 

In the example attached, I would like Category 3 to be moved to the bottom of the report after Category 2.

 

Any ideas?  Thanks in advance.

Jo

1 ACCEPTED SOLUTION

Accepted Solutions
JSJ
Quartz | Level 8 JSJ
Quartz | Level 8

I heeded the warning about monotonic!

 

I tried going into the code and changing the order statements in the PROC Tabulate.

But what ultimately worked was simply padding the category that I wanted first with 3 blanks, next category 2 blanks, etc.

 

Worked!

 

View solution in original post

3 REPLIES 3
JSJ
Quartz | Level 8 JSJ
Quartz | Level 8
I did get my lines reordered by using monotonic() in one query to assign row number, and then a case statement t assign my summary row number in a subsequent query... Now to get it to output!
TomKari
Onyx | Level 15

Be careful about using monotonic, or trying to do this in SQL. SQL is an inherently set-oriented language, and doesn't do "do this line before this line" types of operations well.

 

In your case, it looks to me like you could assign numeric values for your categories in whatever order you want, and then use formats to create the nicely labelled output.

 

Tom

JSJ
Quartz | Level 8 JSJ
Quartz | Level 8

I heeded the warning about monotonic!

 

I tried going into the code and changing the order statements in the PROC Tabulate.

But what ultimately worked was simply padding the category that I wanted first with 3 blanks, next category 2 blanks, etc.

 

Worked!

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 3 replies
  • 1533 views
  • 1 like
  • 2 in conversation