Date: Wed, 30 Jul 2003 07:48:13 -0500
Reply-To: greg.woolridge@TAP.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Greg Woolridge <greg.woolridge@TAP.COM>
Subject: Re: HELP - Data Manipulation
Content-type: text/plain; charset=us-ascii
This code appears to assign the value you want to var2;
data test1;
input id visit $ var1;
cards;
10001 6M 2
10001 12m 2
10001 24m 3
10001 36m 1
10001 60m 3
10002 1m 1
10002 12m 3
10002 36m 3
10002 48m 2
10002 60m 3
;
run;
data test2;
set test1;
by id;
retain testvar;
if first.id then testvar=.;
if var1 in (1,2) then do;
testvar=var1;
var2=var1;
end;
else var2=testvar;
drop testvar;
run;
Greg M. Woolridge
Manager, Study Programming
TAP Pharmaceutical Products Inc.
e-mail: greg.woolridge@tap.com
phone: 847-582-2332
fax: 847-582-2403
Ellen
<erains@NERI.ORG To: SAS-L@LISTSERV.UGA.EDU
> cc:
Sent by: "SAS(r) Subject: HELP - Data Manipulation
Discussion"
<SAS-L@LISTSERV.
UGA.EDU>
07/30/2003 07:26
AM
Please respond
to Ellen
I have a variable that is coded 1 = Yes 2 = No and 3 = Unchanged from last
visit. I need to be able to convert all the "3" to "Yes" or "No" based on
the last visit the variable was recorded as a 'Yes" or "No". A patient may
have several "Unchanged from last visit" interspersed in with Yes and No
answers and for each instance I have to look for the last Yes, No answer
given. See data below:
ID Visit Var1
10001 6M 2
10001 12m 2
10001 24m 3
10001 36m 1
10001 60m 3
10002 1m 1
10002 12m 3
10002 36m 3
10002 48m 2
10002 60m 3
Any thoughts? Thanks