BookmarkSubscribeRSS Feed
veda8
Fluorite | Level 6

Ensure that all values for variable Kilograms are between 40 and 200, inclusively.

  what does the word inclusive mean here

should it be this option 1) ,if so why?

if Kilograms ge 40 or Kilograms le 200 then do;

 is this correct?

 

or should i write kilograms > 40 or kilograms =40 or kilograms =200 or kilograms < 200 them do;

3 REPLIES 3
Reeza
Super User

I usually recommend drawing this out on a number line. So draw a line and then show your condition. 

Ensure that all values for variable Kilograms are between 40 and 200, inclusively.

 

Between 40 and 200, inclusively means the end points are included in the interval. So if you're 39.99 you're outside the interval but if you're 40 you're in the interval.

 

IF  KG_variable >= 40 AND KG_variable <=200 then do;

This is an AND condition, not an OR condition. 

 


@veda8 wrote:

Ensure that all values for variable Kilograms are between 40 and 200, inclusively.

  what does the word inclusive mean here

should it be this option 1) ,if so why?

if Kilograms ge 40 or Kilograms le 200 then do;

 is this correct?

 

or should i write kilograms > 40 or kilograms =40 or kilograms =200 or kilograms < 200 them do;


 

ballardw
Super User

SAS is friendly it allowing intervals to be written, when needed as    value1 < variable < value2 .

So for this one I would use    40 le kilograms le 200

 

Do you remember the difference from a math class between these intervals:

(40, 200)

[40,200)

(40,200]

[40,200]

The [ or ] are the end point of the interval is included (i.e. "inclusive") and ( or ) the end point is not included, (i.e. "exclusive"),

Kurt_Bremser
Super User

The result of the boolean OR operator is true if at least one of its arguments is true. So your condition will be true for all possible values.

You therefore need the AND operator, but SAS nicely allows to concatenate such conditions to

40 le kilograms le 200

 

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 3 replies
  • 499 views
  • 1 like
  • 4 in conversation