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 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1573 views
  • 0 likes
  • 5 in conversation