Date: Tue, 9 Mar 1999 15:58:36 +0000
Reply-To: John Whittington <medisci@POWERNET.COM>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: John Whittington <medisci@POWERNET.COM>
Subject: Re: carrying data forward
Content-Type: text/plain; charset="us-ascii"
At 08:48 09/03/99 +0100, jerry mcgwin, jr. wrote:
>ID VISIT VAR1 VAR2 VAR3...
>01 1 0 3 0
>01 2 1 0 0
>01 3 0 0 1
>...
>
>what i need to do is carry forward data from one visit to the next for each
>subject (for each subject there will be anywhere from 1 to N visits). for
>example, given the above data, i need to end up with the following:
>
>ID VISIT VAR1 VAR2 VAR3...
>01 1 0 3 0
>01 2 1 3 0
>01 3 1 3 1
>...
Jerry, from the example you have given, I presume that you want to 'carry
forward' only into values which are otherwise zero (which I suspect may
actually indicate 'missing') - which is a very common task in clinical trial
data analysis. If that is the case, then something like the following
should do what you want:
data do_it (drop = i last1 - last3) ;
array a(*) var1 - var3 ; * or whatever variable list ;
array last(*) last1 - last3 ; * adjust number of vars to suit data ;
retain last1 - last3 ; * as above ;
set yourdata ;
by id ;
if first.id then do ;
do i = 1 to dim(a) ; last(i) = 0 ; end ;
end ;
do i = 1 to dim(a) ;
if a(i) = 0 then a(i) = last(i) ;
last(i) = a(i) ;
end ;
run ;
Any help ?
Regards,
John
----------------------------------------------------------------
Dr John Whittington, Voice: +44 (0) 1296 730225
Mediscience Services Fax: +44 (0) 1296 738893
Twyford Manor, Twyford, E-mail: medisci@powernet.com
Buckingham MK18 4EL, UK mediscience@compuserve.com
----------------------------------------------------------------
|