DATA Step, Macro, Functions and more

Finding Missing Medication Date with in a specified period

Reply
New Contributor
Posts: 2

Finding Missing Medication Date with in a specified period

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

Super User
Super User
Posts: 7,997

Re: Finding Missing Medication Date with in a specified period

Posted in reply to Sandy1985

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.

Respected Advisor
Posts: 4,937

Re: Finding Missing Medication Date with in a specified period

Posted in reply to Sandy1985

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;
PG
Super User
Posts: 10,048

Re: Finding Missing Medication Date with in a specified period

Posted in reply to Sandy1985
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;


Ask a Question
Discussion stats
  • 3 replies
  • 213 views
  • 1 like
  • 4 in conversation