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.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.