BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
ChickenLittle
Obsidian | Level 7

Hi, 

 

I'm trying to format a field. The field is called "Score" and it is a 3 digit number (and it is specified as a number with a length of 8). However, the code is not grouping them as desired. It appears to be bouncing back the same score for each observation. Can someone tell me what I am doing wrong?

 

proc format;
value $ScoreFormat
1-599 ='<600'
600-640 ='600-640'
641-680 ='641-680'
681-720 ='681-720'
721-760 ='721-760'
761-999 ='761+ '
. ='Missing';
run;

 

data temp2;
set temp1;
Score_Band = put( Score ,$ScoreFormat.);
run;

 

Example fields:

Acct          Score

1                550

2                665

3                775

 

Output:

Acct          Score_Band

1                550

2                665

3                775

 

Desired Output:

Acct          Score_Band

1              <600

2                641-680

3                761+

 

Thank you in advance.

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Try creating a numeric format - note I've just removed the dollar sign on the front. If you are applying a format to a numeric variable the format must also be numeric:

proc format;
value ScoreFormat
1-599 ='<600'
600-640 ='600-640'
641-680 ='641-680'
681-720 ='681-720'
721-760 ='721-760'
761-999 ='761+ '
. ='Missing';
run;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

Try creating a numeric format - note I've just removed the dollar sign on the front. If you are applying a format to a numeric variable the format must also be numeric:

proc format;
value ScoreFormat
1-599 ='<600'
600-640 ='600-640'
641-680 ='641-680'
681-720 ='681-720'
721-760 ='721-760'
761-999 ='761+ '
. ='Missing';
run;
ChickenLittle
Obsidian | Level 7
Thanks! That worked!

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
  • 2 replies
  • 1016 views
  • 2 likes
  • 2 in conversation