I need to repeat a sas datastep using macro. I have two sets of dates, stimulant prescription dates "stim_1" to "stim_190" and opioid prescription dates "_1" to "_825". I am interested to see if these prescriptions are concurrent prescriptions - if they are within 30 days of each other. So, I have written the following code to calculate: data opi.concurrent_test;
set opi.concurrent_merged;
concurrent_1 = 0;
array bupe [825] _1 - _825;
if not missing (stim_1) then do i = 1 to 825;
concurrent_1 = (0 le (stim_1- bupe (i)) le 30);
if concurrent_1 = 1 then leave;
end;
drop i;
if (_1 - _825) | stim_1 = . then concurrent_1 = .;
if concurrent_1 = 1 then concurrent_1 = year(stim_1);
run; But now, I need to run this for all 190 stimulant dates. How can I write a macro to repeat this procedure 190 times. Thank you!
... View more