DATA Step, Macro, Functions and more

sas automaticaly removes '-'

Accepted Solution Solved
Reply
Frequent Contributor
Frequent Contributor
Posts: 101
Accepted Solution

sas automaticaly removes '-'

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,


Accepted Solutions
Solution
‎08-26-2016 09:01 AM
Frequent Contributor
Frequent Contributor
Posts: 101

Re: sas automaticaly removes '-'

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

View solution in original post


All Replies
Trusted Advisor
Posts: 1,353

Re: sas automaticaly removes '-'

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

Super User
Posts: 6,928

Re: sas automaticaly removes '-'

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
---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Solution
‎08-26-2016 09:01 AM
Frequent Contributor
Frequent Contributor
Posts: 101

Re: sas automaticaly removes '-'

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

Super User
Posts: 17,748

Re: sas automaticaly removes '-'

@ari please mark the question solved. 

Regular Contributor
Posts: 239

Re: sas automaticaly removes '-'

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

☑ This topic is SOLVED.

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

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