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

I have character variable with numerical values...While sorting I am getting the following way.....is there way that i can get as 1,2,3,4,5,6,,7,8 instead of 1,1,10,10,11,11

100010002    1

100010002    1

100010002    10

100010002    10

100010002    11

100010002    11

100010002    11

100010002    12

100010002    12

100010002    13

100010002    13

100010002    2

100010002    2

100010002    3

100010002    4

100010002    5

100010002    6

100010002    7

100010002    8

100010002    8

1 ACCEPTED SOLUTION

Accepted Solutions
Haikuo
Onyx | Level 15

proc sort data=have SORTSEQ=LINGUISTIC;

by x; run;

View solution in original post

4 REPLIES 4
Haikuo
Onyx | Level 15

proc sort data=have SORTSEQ=LINGUISTIC;

by x; run;

data_null__
Jade | Level 19

Do you need numeric_collation sub-option?

rakeshvvv
Quartz | Level 8

I have charceter variable but it has only numeric values........so i would like do sorting the way we do it for numeric but for character variable......

Haikuo
Onyx | Level 15

Yes, DN, you are right, so for Proc Sort:

proc sort data=have SORTSEQ=LINGUISTIC (numeric_collation=on)

by x; run;

Or if using Proc SQL:

proc sql;

create table want (drop=skey) as

  select *, sortkey(x,'','','','NUMERIC','') as skey

  from have

order by skey;

quit;

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!

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
  • 842 views
  • 0 likes
  • 3 in conversation