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!

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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