BookmarkSubscribeRSS Feed
Stepik
Obsidian | Level 7

Hello,

When I try to set the next condition on the if statement that determines the value between 2 numbers, the result unfortunately does not take this condition into account and calculates it as there would be no such a condition:

 

else if ke ne 1 and sales = 0 and (0 < other < 50000000) then do;

 

What is wrong?

 

Thanks,

Stefan

 

4 REPLIES 4
LinusH
Tourmaline | Level 20

Why not just omit the "between" logic and split into two conditions?

Data never sleeps
Reeza
Super User

This seems to work fine for me. 

Do you need to round/fuzz the 0 comparison?

 

data have;
do ke=0,1;
do sales=0 to 4;
do other=1000000 to 8000000 by 1000000;
output;
end;
end;
end;
run;

data want;
set have;

 if ke ne 1 and sales = 0 and (0 < other < 50000000) then do;
 flag=1;
 end;
 else flag=0;
 run;
ballardw
Super User

What does the code look like before the ELSE? You may never get to this "condition" because of prior code and values.

What is the value of KE, Sales and OTHER?

What is the calculation performed and values of the variables involved?

 

No data, incomplete code, no actual evidence of incorrect anything in this case.

 

Please do not chop stuff up and then expect us to mind read the contents of needed code and values of variables.


@Stepik wrote:

Hello,

When I try to set the next condition on the if statement that determines the value between 2 numbers, the result unfortunately does not take this condition into account and calculates it as there would be no such a condition:

 

else if ke ne 1 and sales = 0 and (0 < other < 50000000) then do;

 

What is wrong?

 

Thanks,

Stefan

 


 

PaigeMiller
Diamond | Level 26

@Stepik wrote:

Hello,

When I try to set the next condition on the if statement that determines the value between 2 numbers, the result unfortunately does not take this condition into account and calculates it as there would be no such a condition:

 

else if ke ne 1 and sales = 0 and (0 < other < 50000000) then do;


You haven't told us what you see in the output that seems to be incorrect. What do you see that you think is incorrect? Please be specific. Also please show us sample data.

--
Paige Miller

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 4 replies
  • 1205 views
  • 2 likes
  • 5 in conversation