Help using Base SAS procedures

SORTING

Accepted Solution Solved
Reply
Super Contributor
Posts: 1,040
Accepted Solution

SORTING

when we have a charecter variable which has values like shown below:

0,1,2,3,4, MISSING(word)

HOW DOES IT SORT??????

i am getting the followwing order:

0

1

2

3

4

MISSING

Is there any way we can do :

MISSING

0

1

2

3

4

Thanks


Accepted Solutions
Solution
‎12-19-2013 03:50 PM
Super User
Posts: 10,466

Re: SORTING

You can specify a COLLATING SEQUENCE in proc sort that would do that. But you will have to make it.

Or a translation table Proc Trantab gets you started.

Personally, I wouldn't have made them character if I wan'ted them to sort that way as Missing, as a numeric, comes first, especially if all the values concerned except MISSING are number values. Then us a FORMAT to display the text if that's important.


View solution in original post


All Replies
Super Contributor
Posts: 307

Re: SORTING

What technique are you using to perform the sort? PROC SORT? PROC SQL? Something else? What platform are you running SAS on?

Super Contributor
Posts: 1,040

Re: SORTING

I was trying to acheive this in PROC REPORT...

Thanks

Super Contributor
Posts: 307

Re: SORTING

The quickest way would be to recode the variable to numeric.

Solution
‎12-19-2013 03:50 PM
Super User
Posts: 10,466

Re: SORTING

You can specify a COLLATING SEQUENCE in proc sort that would do that. But you will have to make it.

Or a translation table Proc Trantab gets you started.

Personally, I wouldn't have made them character if I wan'ted them to sort that way as Missing, as a numeric, comes first, especially if all the values concerned except MISSING are number values. Then us a FORMAT to display the text if that's important.


☑ This topic is SOLVED.

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

Discussion stats
  • 4 replies
  • 227 views
  • 3 likes
  • 3 in conversation