Date: Tue, 5 May 2009 21:21:35 -0400
Reply-To: Akshaya <akshaya.nathilvar@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Akshaya <akshaya.nathilvar@GMAIL.COM>
Subject: Re: Data Manipulation
In-Reply-To: <200905051855.n45GIOM9000894@malibu.cc.uga.edu>
Content-Type: text/plain; charset=ISO-8859-1
A simple DOW loop helps:
Data want;
do until(last.id);
set have;
by id;
if status='PD' then _status='PD';
_status=coalescec(_status,status);
output;
end;
Run;
On Tue, May 5, 2009 at 2:55 PM, Sid <sjain@aveopharma.com> wrote:
> Hello,
>
> I have a dataset like below:
>
> data sample;
> input id visit status $;
> cards;
> 1 1 CR
> 1 2 PR
> 1 3 SD
> 1 4 PD
> 2 1 CR
> 2 2 PD
> 2 3 SD
> 2 4 PR
> 3 1 PD
> 3 2 PD
> 3 3 SD
> 3 4 CR
> ;
> run;
>
> If status has a value of PD, I need to assign status as PD for all the
> following visits for that id.
>
> e.g. ids 2 and 3 should be:
>
> 2 1 CR
> 2 2 PD
> 2 3 PD
> 2 4 PD
> 3 1 PD
> 3 2 PD
> 3 3 PD
> 3 4 PD
>
> Pls guide.
>
> Thanks in advance,
> Sid
>
--
AkshayA!
|