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

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

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

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

4 REPLIES 4
Fugue
Quartz | Level 8

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

robertrao
Quartz | Level 8

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

Thanks

Fugue
Quartz | Level 8

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

ballardw
Super User

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.


sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 4 replies
  • 897 views
  • 3 likes
  • 3 in conversation