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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

New Learning Events in April

 

Join us for two new fee-based courses: Administrative Healthcare Data and SAS via Live Web Monday-Thursday, April 24-27 from 1:00 to 4:30 PM ET each day. And Administrative Healthcare Data and SAS: Hands-On Programming Workshop via Live Web on Friday, April 28 from 9:00 AM to 5:00 PM ET.

LEARN MORE

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