BookmarkSubscribeRSS Feed
alaxman
Obsidian | Level 7

I have this piece of code:

 

if filldates(i)<= start_dt + ii -1 <= filldates(i)+days_supply(i)-1
		then daydummy(ii)=1;
		end;

Can someone help me understand what the IF statement is checking? There doesn't seem to be an AND or an OR operator, but two conditional operators (<=). 

5 REPLIES 5
SASKiwi
PROC Star

As I understand it, the IF condition is true if (start_dt + ii -1) is between the values of (filldates(i)) and (filldates(i)+days_supply(i)-1).

 

The lack of brackets in this expression is concerning and would make it easier to read:

if filldates(i) <= (start_dt + ii -1) <= (filldates(i)+days_supply(i)-1)
		then daydummy(ii)=1;
		end;

 

 

Tom
Super User Tom
Super User

A < B < C is shorthand for A<B AND B<C.

I assume that filldates and days_supply are array names and i is the index into the array.  Although they could be user defined functions.

 

Stick your condition into a WHERE statement and SAS will show you how it is interpreted in the LOG.

908   data _null_;
909     set sashelp.class;
910     where AGE <= HEIGHT <= WEIGHT ;
911   run;

NOTE: There were 18 observations read from the data set SASHELP.CLASS.
      WHERE (AGE<=HEIGHT) and (HEIGHT<=WEIGHT);
alaxman
Obsidian | Level 7
Thank you!
tarheel13
Rhodochrosite | Level 12

It means start_dt + ii -1 is >= filldates(i) AND start_dt + ii - 1 is <= filldates(i) + days_supply(i)-1.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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