Hi, I am working on the prescription dataset from a health organization. the dataset contains the following variables in the snapshot below. I want to count a number prescription per patient based on the following criteria, If the deliv_date2 is less than seven and the same ATC code for the individual patient then set a number of prescription is equal to one and sum DDD otherwise count the number of prescription. Thank you in advance!! data thesis.presc2;
set thesis.presc;
by patient;
if first.patient then lastdate=.;
else lastdate = lag(deliv_date2);
datediff = deliv_date2-lastdate;
run;
proc sql;
CREATE table thesis.presc3 as
select patient, reimburs_cat, source, atc, AdminRoute, N_presc, count(N_presc) as Co_Pres, Center, deliv_date2, DDD,datediff
From thesis.presc2
where datediff >= 7
group by patient ;
quit;
... View more