Date: Fri, 19 Jun 2009 11:39:18 -0400
Reply-To: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Gerhard Hellriegel <gerhard.hellriegel@T-ONLINE.DE>
Subject: Re: AE Derived Variable
I think a one-pass solution is complicated if you need the YES in the
actual AND the previous obs. For that you must "prefetch" the next obs to
get it. More complicated, I think, if there are more than 2 aeterm
records. So for me the easy way (there is a elegant SQL solution for sure,
but that's not the easy way for me...):
data test;
infile cards;
input
patno aeterm:$20. aesev stdt: date9. dsdt:date9. ;
cards;
1 Headache 1 12JUN08 15JUN08
1 fatigue 2 11JUN08 15JUN08
1 Headache 3 17JUN08 15JUN08
;
run;
proc sort data=test out=a;
by patno aeterm aesev stdt;
run;
data b;
set a;
by patno aeterm aesev stdt;
retain sev;
if first.aeterm then do;
sev=aesev;
end;
if last.aeterm and aesev>sev then output;
keep patno aeterm;
run;
data result;
merge a b(in=inb);
by patno aeterm;
length taae $5;
taae = "NO";
if inb then taae="YES";
run;
proc sort;
by patno stdt;
format stdt dsdt date9.;
run;
or whatever you want as order...
Gerhard
On Tue, 16 Jun 2009 13:27:41 -0700, Al <ali6058@GMAIL.COM> wrote:
>Hi All:
>
>I have an ae dataset in the following way
>
>patno aeterm aesev stdt dsdt TEAE(Dervied)
>1 Headache 1 12JUN08 15JUN08 YES
>1 fatigue 2 11JUN08 15JUN08 NO
>1 Headache 3 17JUN08 15JUN08 YES
>
>I am supposed to create an derived variable TEAE
>where stdt >= dsdt or if the ae event's severity has increased
>after the dose was given .. example:First obs in the above
>example has ae occured prior to date of dose..but the same
>ae (Third obs) severity has increased from 1 to 3 in number.
>so i want 'YES' in column (TEAE --Derived Variable) for both
>first and third obs ..
>How can it be accomplished
>
>Thanks in advance