BookmarkSubscribeRSS Feed
madhu
Calcite | Level 5
I have a situation where subject is receiving drug twice a day. I have to identify subjects missing 4 or more consecutive doses. I am using the following code - where USUBJID is subject number and EXDT is date. However with d >= 2 it is listing even if the subject missses 2 doses on the same day. IF I use d >2 it does not list subjects if 4 consecutive doses are missed in 3 days. Any suggestions are appreciated

Thanks in advance.


data miss2;
f=0;
do until(last.USUBJID);
set EX_BID;
by USUBJID;
d = ifn(not first.USUBJID,dif(EXDT),0);

if d ge 2 then do;
output;

f=1;
end;
end;
run;
2 REPLIES 2
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Hello Madhu,

This could be a solution to your problem:
[pre]
proc freq data=EX_BID noprint;
tables EXDT/nopct out=freq(where=(Count <= 2));
by USUBJID;
run;
[/pre]
Sincerely,
SPR
SPR
Quartz | Level 8 SPR
Quartz | Level 8
Sorry, it looks like I did not understand your problem. So, the above code is only a part of the solution. Please submit a sample of your data then it will be easier to get into a solution. This is my second attempt:
[pre]
proc freq data=EX_BID noprint;
tables EXDT/out=freq (where=(Count < 2));
by USUBJID;
run;
data miss;
set freq;
miss=2-count;
run;
proc transpose data=miss out=M prefix=M;
var miss;
by USUBJID;
run;
proc transpose data=miss out=D prefix=D;
var EXDT;
by USUBJID;
run;
data tr;
merge d m;
by USUBJID;
run;
data r;
set tr;
array d d:;
array m m:;
if DIM(d) > 1 then do;
do i=2 to DIM(d);
if 2 <= SUM(d[i],-d[i-1]) then output;
else if 1 = SUM(d[i],-d[i-1]) then do;
if 4 <= 2+SUM(m[i],m[i-1]) then output;
end;
end;
end;
keep USUBJID D:;
run;
[/pre]
SPR

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

Health and Life Sciences Learning

 

Need courses to help you with SAS Life Sciences Analytics Framework, SAS Health Cohort Builder, or other topics? Check out the Health and Life Sciences learning path for all of the offerings.

LEARN MORE

Discussion stats
  • 2 replies
  • 1637 views
  • 0 likes
  • 2 in conversation