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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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