Hello,
I am trying to determine whether each patient has a gap btw the two prescriptions (drug A and B) and episode is same within each patient ID.
/*PDC for drug a*/
data pd1;
set drugA_datedays;
array daydummy(1460) day1-day1460;/*set up an array that has 1460 variables: day1 to day 1460 ie 4 years*/
array dd(*) dispdate1 - dispdate220; /* The highest number of Rxs and set up an array for the dispense date*/
array ss(*) days_supply1-days_supply220; /* same for days supply*/
do ii=1 to 1460; daydummy(ii)=0;end;
do ii=1 to 1460;/*Loop will go from 1-365. Outer loop process inner loop 365 times*/
do i = 1 to dim(dd) while (dd(i) ne .);
/*for each person, loop through their total number of Rxs.
Will continue to count as long as there is not a ‘.’ For dd (dispdate); dim returns how many are in the array*/
if dd(i)<= start_dt + ii -1 <= dd(i)+ss(i)-1
then daydummy(ii)=1;
end;
end;
drop i ii;
dayscovered=sum(of day1 - day1460);
label dayscovered='Total Days Covered';
p_dayscovered=(dayscovered/1460)*100;
label p_dayscovered='Proportion of Days Covered';
run;