BookmarkSubscribeRSS Feed
apple
Calcite | Level 5

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

4 REPLIES 4
PGStats
Opal | Level 21

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

PG
Tom
Super User Tom
Super User

'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' .

apple
Calcite | Level 5

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!

Tom
Super User Tom
Super User

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 4 replies
  • 772 views
  • 0 likes
  • 3 in conversation