BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Hello all:

I am attempting to find a way to specify the order of data within a column when the order is not simply ascending/descending. For example my dataset will have

COLUMN HEADER
W
X
Y
Z

But in my output I need the order to be

COLUMN HEADER
X
Z
Y
W

i.e. not alphabetical or reversed-alphabetical order, but a specific one. I can preserve the order of the data after running a List Report, but I have been unable to run a filter (or whatever the process is) to get the data into the correct order before a Report step.

If anyone has any thoughts or suggestions, I’d appreciate them.
-Steven
2 REPLIES 2
Doc_Duke
Rhodochrosite | Level 12
Add a column that represents sort order and then do the appropriate transformations/data entry to allow you to do an ascending or descending sort.

Depending on the procedures that you are using, you may be able to do this with a format (some procedures will display in the formatted order).
RichardH_sas
SAS Employee
All of Doc's suggestions are right on the money. The lazy person's solution would be to recode the column so the values are:

1 - X
2 - Z
3 - Y
4 - W

If this is acceptable, it's definitely a simple solution (and one I've used many, many times). If you MUST have the values stay X, Y, W, Z; I would recommend Doc's approach of recording the values similar to above (1 - X, 2 - Z,...) and creating a custom format that causes 1 - X to display as X. If you then order by the Unformatted values, you're good to go. As Doc mentions, this trick will not necessarily works in every possible situation, though it works in most of them.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 646 views
  • 0 likes
  • 3 in conversation