BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Solly7
Pyrite | Level 9

Hi, i need help in allocating score bands to the corresponding save_ratio.. i tried the below code but it returns null values 'dot' in the output  "Saves_Ratio_Score'

 

data retentions;
  input Save_Ratio user : $20. Band_Indicator $;
  datalines;
0.45 ALUPIYA I
0.37 DLOUIS I
0.6 DMORAKE I
0.30 FDANISA O
0.50 FFARAO O
;

proc format;
   invalue inbound_ratio_band
      low  -< 0.35   = 0
      0.35 -< 0.43 = 0.08
      0.43 -< 0.473   = 0.16
      0.473 -< 0.52 = 0.24
      0.52 -< 0.59  = 0.32
      0.59 - high = 0.4
   ;
run;

proc format;
   invalue outbound_ratio_band
      low  -< 0.34   = 0
      0.34 -< 0.41 = 0.08
      0.41 -< 0.45   = 0.16
      0.45 -< 0.5 = 0.24
      0.5  -< 0.56 = 0.32
      0.56  - high = 0.4
   ;
run;

data fix_bands;
    SET retentions;
	IF	UPCASE(Band_Indicator)	=	'I'	THEN
		Saves_Ratio_Score	= INPUT(Save_Ratio,Inbound_ratio_band.);
	ELSE
	IF	UPCASE(Band_Indicator)	=	'O'	THEN
		Saves_Ratio_Score	= INPUT(Save_Ratio,Outbound_ratio_band.);
	CALL	MISSING(Saves_Ratio_Score);
run;

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

You first assign a value to Saves_Ratio_Score but then before writing the data to the target table you execute always:

CALL MISSING(Saves_Ratio_Score);

 

This sets the variable always to missing. Just remove this statement and things should work for you as expected.

View solution in original post

3 REPLIES 3
Solly7
Pyrite | Level 9
I added ELSE after the last THEN..but it still dont work

data fix_bands;
SET retentions;
IF UPCASE(Band_Indicator) = 'I' THEN
Saves_Ratio_Score = INPUT(Save_Ratio,Inbound_ratio_band.);
ELSE
IF UPCASE(Band_Indicator) = 'O' THEN
Saves_Ratio_Score = INPUT(Save_Ratio,Outbound_ratio_band.);
ELSE
CALL MISSING(Saves_Ratio_Score);
run;
Patrick
Opal | Level 21

You first assign a value to Saves_Ratio_Score but then before writing the data to the target table you execute always:

CALL MISSING(Saves_Ratio_Score);

 

This sets the variable always to missing. Just remove this statement and things should work for you as expected.

Solly7
Pyrite | Level 9
Thanks a lot Patrick..your solutions works!

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 3 replies
  • 869 views
  • 1 like
  • 2 in conversation