BookmarkSubscribeRSS Feed
Sandy1985
Calcite | Level 5

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

3 REPLIES 3
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

PGStats
Opal | Level 21

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
Ksharp
Super User
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;


hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 1170 views
  • 1 like
  • 4 in conversation