I have the following code that I want to be able to run as an array (or a macro) within a larger datastep. In the following code I have an admission date (admit_dt) and Discharge date (disch_dt) where on the date condition I create two new variables, caldate and rcaldate. As you can see I have the condition that if the admission date is <= Dec 31, 2019 and the discharge date is >= Jan 1 2019 then create caldate and rcaldate. What I would like to do is that I would like to run this for a 4 years of data (2017, 2018, 2019 and 2020) and create the variable caldate17, caldate18, caldate19 and caldate20 and then rcaldate7, rcaldate18, rcaldate19 and rcaldate20 . Instead of copy and pasting this code four times, how can I create an array (or a macro) for the below code? if (admit_dt<='31dec2019'd and disch_dt>='01jan2019'd ) then do;
if admit_dt<'01jan2019'd then caldate19='01jan2019'd;
else caldate19=admit_dt;
if dshy = . or disch_dt>='31dec2019'd then rcaldate19='31dec2019'd;
else if dshy ne . and disch_dt=< '31dec2019'd then rcaldate19= srdate;
end; Thank you!
... View more