Date: Sat, 16 Aug 1997 18:09:45 +-300
Reply-To: 001 <jucha@NETVISION.NET.IL>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: 001 <jucha@NETVISION.NET.IL>
Subject: Re: Crack this
Content-Type: text/plain; charset="us-ascii"
Henrik wrote:
>>> I have a number of patients with a number of event dates. I would like
>>> to create datasets with patients who have more than one event at the
>>> same date, more than one event within 1, 2, 3, 4, 5, 6, 7 days.
>>> My dataset looks something like this:
>>> PATID EVENTDAT
>>> 1 970303
>>> 1 970303
>>> 1 970405
>>> 2 970205
>>> 3 960725
>>> 3 960830
>>> 3 960902
>>> Maybe I can use the lag function but I am not sure how to code for this
>>> problem.
>>> Any suggestions?
Dear Henrik,
I suggest you to try the following:
data a;
input EVENTDAT yymmdd6. PATID;
cards;
970303 1
970303 1
970405 1
970205 2
960725 3
960830 3
960902 3
;
run;
proc sort data=a;by patid eventdat;run;
data a0(keep=patid) a3(keep=patid) out(keep=patid);
set a;
by patid;
retain mindif;
ddat=dif(eventdat);
if first.patid then do;
ddat=.;
mindif=.;
end;
mindif=min(ddat,mindif);
if last.patid;
if mindif=0 then output a0;
if mindif=3 then output a3;
if mindif=. or 7<mindif then output out;
run;
Elik Jucha
Statistics
|