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-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!

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
  • 539 views
  • 3 likes
  • 4 in conversation