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

Hi,

I need some help with creating groups this is what i want:

 

IF value1 < 33 then score = 20 ;
IF value1 < 33.5 then score = 12 ;
IF value1 < 34 then score = 13 ;
IF value1 < 35 then score = 3 ;
IF value1 < 36 then score = 2 ;
Else score = 4 ;

 

its not giving me the values I need . The cutoff eg. for the first row should be 33 and second should be 33.5?

 

Any ideas.

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@AZIQ1 wrote:

Hi,

I need some help with creating groups this is what i want:

 

IF value1 < 33 then score = 20 ;
IF value1 < 33.5 then score = 12 ;
IF value1 < 34 then score = 13 ;
IF value1 < 35 then score = 3 ;
IF value1 < 36 then score = 2 ;
Else score = 4 ;

 

its not giving me the values I need . The cutoff eg. for the first row should be 33 and second should be 33.5?

 

Any ideas.


Multiple if statements as you have are all evaluated. So the LAST one in that is true gets teh assignment. That is what the ELSE does to the part after ELSE only when the immediately previous is not true.

You may also consider

IF 33 le value1 < 34 then score = 13

to set specific ranges.

View solution in original post

2 REPLIES 2
art297
Opal | Level 21

Add elses to all but the first if statement. i.e.,

 

IF value1 < 33 then score = 20 ;
else IF value1 < 33.5 then score = 12 ;
else IF value1 < 34 then score = 13 ;
else IF value1 < 35 then score = 3 ;
else IF value1 < 36 then score = 2 ;
Else score = 4 ;

HTH,

Art, CEO, AnalystFinder.com

 

ballardw
Super User

@AZIQ1 wrote:

Hi,

I need some help with creating groups this is what i want:

 

IF value1 < 33 then score = 20 ;
IF value1 < 33.5 then score = 12 ;
IF value1 < 34 then score = 13 ;
IF value1 < 35 then score = 3 ;
IF value1 < 36 then score = 2 ;
Else score = 4 ;

 

its not giving me the values I need . The cutoff eg. for the first row should be 33 and second should be 33.5?

 

Any ideas.


Multiple if statements as you have are all evaluated. So the LAST one in that is true gets teh assignment. That is what the ELSE does to the part after ELSE only when the immediately previous is not true.

You may also consider

IF 33 le value1 < 34 then score = 13

to set specific ranges.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 758 views
  • 2 likes
  • 3 in conversation