Desktop productivity for business analysts and programmers

Specify order of data within a column

Reply
N/A
Posts: 0

Specify order of data within a column

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
Trusted Advisor
Posts: 2,114

Re: Specify order of data within a column

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).
SAS Employee
Posts: 149

Re: Specify order of data within a column

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.
Ask a Question
Discussion stats
  • 2 replies
  • 113 views
  • 0 likes
  • 3 in conversation