The prtocol for the study working on specifies, that a patient is to be dosed everyday for a period of time. The raw data is below.
Patient Dosedate
101 01/01/2015
101 01/02/2015
101 01/03/2015
101 01/04/2015
102 01/05/2015
102 01/06/2015
102 01/08/2015
102 01/10/2015
How can Identify a patient who missed a consecutive dose?
Example: Patient102 missied dose on 01/07/2015 and 01/09/2015.
Thanks
Hi,
Retain or lag. Eg.
data want; set have; by patient; retain lstdate; if first.patient then lstdate=dosedate; else do; if dosedate ne lstdate + 1 then flag=1; lstdate=dosedate; end; run;
Not tested.
Or use SQL and the fact that dates are numbers of days
proc sql;
create table missingPatient as
select Patient
from have
group by Patient
having range(DoseDate) + 1 > count(distinct doseDate);
select * from missingPatient;
quit;
data have; input Patient Dosedate: mmddyy10.; format Dosedate mmddyy10.; cards; 101 01/01/2015 101 01/02/2015 101 01/03/2015 101 01/04/2015 102 01/05/2015 102 01/06/2015 102 01/08/2015 102 01/10/2015 ; run; data want; merge have have(firstobs=2 rename=(Patient=_Patient Dosedate=_Dosedate)); output; if Patient=_Patient then do; do i=Dosedate+1 to _Dosedate-1; Dosedate=.;miss_date=i;output; end; end; format miss_date mmddyy10.; drop i _:; run;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.