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 (<=).
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;
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);
It means start_dt + ii -1 is >= filldates(i) AND start_dt + ii - 1 is <= filldates(i) + days_supply(i)-1.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.