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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.