proc format;
value $LOAN_NUM_YR_LFT_CNT
'0'='0'
'0'<-'10'='0<-10'
'10'<-'29'='10<-29'
'30'-'35'='30-35'
'35'<-high='Above 35'
;
run;
When I use this format for a character variable, a separate column is created for 3 when it should be included in '0<-10', how to correct this error?
Thanks
You are asking for trouble; but anyway, if your strings all represent integers between 0 and 99, I think you could get away with:
proc format;
value $LOAN_NUM_YR_LFT_CNT
'0'='0'
'1'-'9', '10'='0<-10'
'11'-'29'='10<-29'
'30'-'35'='30-35'
'36'-high='Above 35'
;
run;
The result will depend on the character collating sequence in use.
PG
'3' is not included in any of the ranges you have listed.
'3' is larger than '10' since '3' comes after '1' .
'3' is larger than '29' since '3' comes after '2'.
'3' is smaller than '30' since ' ' (space) comes before '0' .
Thanks for the reply.
But I don't understand how SAS read range for character variable format.
"'3' is smaller than '30' since ' ' (space) comes before '0' ." I don't understand.
Can someone explain things more clearly so I won't make the same mistake?
Thank you a lot!
It is like looking up a word in a dictionary. Just like 'A ' is smaller than 'AZ'.
To see the relative order of all characters look at a chart of ASCII codes. ASCII Code - The extended ASCII table
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.