Date: Mon, 5 May 2008 17:09:59 -0400
Reply-To: CP Jen <plessthanpointohfive@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: CP Jen <plessthanpointohfive@GMAIL.COM>
Subject: Re: Splitting person time based on risk period after exposure
Thanks to data_null_; for solving the quirks of my problem, which grew
from my original question.
After my original question I wanted to created multiple subsequant or
concurrant risk periods of pre-specified length.
Here's how it works:
data have(index=(id)); *notice index created for HAVE;
infile cards missover;
input id:$1. (dob start end index imm1-imm8)(:mmddyy.);
format _numeric_ mmddyy.;
cards;
1 6/18/74 6/30/99 12/31/05 8/4/00 3/19/00 10/14/02 8/15/03 8/30/03
2 4/18/74 6/30/99 12/31/05 8/4/00 3/19/00 10/14/02 8/15/03 8/30/03
12/21/03
3 6/18/74 6/30/99 11/18/03 8/4/00 3/19/00 10/14/02 8/15/03 8/30/03
;;;;
run;
proc print;
run;
data work.imm(keep=id risk date) / view=work.imm;
set work.have;
array imm[*] imm: dummy;
do risk = 1 to dim(imm);
if missing(imm[risk]) then continue;
do date = imm[risk] to min(imm[risk+1]-1,imm[risk]+125);
if date gt end then leave;
output;
end;
end;
format date mmddyy.;
run;
data work.dates(keep=id age date) / view=work.dates;
set have;
age = floor(yrdif(dob,start,'ACT/ACT'));
do date = start to end;
if day(date) eq day(dob) and month(date) eq month(dob) then age + 1;
output;
end;
format date mmddyy.;
run;
data work.allV1 / view=work.allV1;
merge work.dates work.imm;
by id date;
run;
proc summary data=work.allV1;
by id age risk notsorted;
output
out=work.summary(drop=_type_ rename=(_freq_=days))
min(date)=start
max(date)=end
;
run;
data work.close2need;
set work.summary(rename=(risk=risk0));
by id risk0 notsorted;
if first.id then risk = 0;
else if first.risk0 then risk + 1;
dose = not missing(risk0);
call missing(dx,index);
set work.have(keep=id index) key=id / unique;
dx = start le index le end;
drop index;
run;
proc print;
run;
proc print;
by id age;
id id age;
var risk dose dx days start end;
run;