Identify Subjects missing 4 or more consecutive doses

Reply
Contributor
Posts: 27

Identify Subjects missing 4 or more consecutive doses

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;
Super Contributor
Super Contributor
Posts: 365

Re: Identify Subjects missing 4 or more consecutive doses

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
Super Contributor
Super Contributor
Posts: 365

Re: Identify Subjects missing 4 or more consecutive doses

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
Post a Question
Discussion Stats
  • 2 replies
  • 331 views
  • 0 likes
  • 2 in conversation