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

Hi,

 

I am sorting a dataset with id's

Have:

BR01-999-1001-002
BR01-999-1045-004

 

when i sort them, in the output the ids look like,

BR01-999-1001002
BR01-999-1045004

 

Any way the sort the data while keeping Ids as such in the input dataset??

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
ari
Quartz | Level 8 ari
Quartz | Level 8

this was an issue due to source dataset. thanks for the help though

View solution in original post

5 REPLIES 5
Shmuel
Garnet | Level 18

Check the format and the format length (how many digits) has the ID variable.

Kurt_Bremser
Super User

Post your code.

 

data have;
input key $17.;
cards;
BR01-999-1001-002
BR01-999-1045-004
;
run;

proc print noobs;
run;

proc sort
  data=have
  out=want
;
by key;
run;

proc print noobs;
run;

gives this result

        key

 BR01-999-1001-002
 BR01-999-1045-004
                   

        key

 BR01-999-1001-002
 BR01-999-1045-004
ari
Quartz | Level 8 ari
Quartz | Level 8

this was an issue due to source dataset. thanks for the help though

Reeza
Super User

@ari please mark the question solved. 

RahulG
Barite | Level 11

Check data in the input data set. It might have read incorrectly while reading from source 

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!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 988 views
  • 0 likes
  • 5 in conversation