Date: Wed, 8 Feb 2012 15:41:01 +0000
Reply-To: "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Zdeb, Michael S" <mzdeb@ALBANY.EDU>
Subject: Re: Conditional renaming problem.
Content-Type: text/plain; charset="us-ascii"
hi ... RENAME statements are DECLARATIVE, not EXECUTABLE
so ... you cannot write data step logic that has RENAME vary based on "stuff" that happens during the running of the data step
another idea ...
r1(where=(reader eq 1) rename=(date=r1date))
r2(where=(reader eq 2) rename=(date=r2date));
U@Albany School of Public Health
One University Place (Room 119)
Rensselaer, New York 12144-3456
From: SAS(r) Discussion [SAS-L@LISTSERV.UGA.EDU] on behalf of Brian Wallace [brian_c_wallace@YAHOO.COM]
Sent: Wednesday, February 08, 2012 7:32 AM
Subject: Conditional renaming problem.
I'm sorry. This is definitely something really stupid I'm doing but I could really use another set of eyes:
INPUT CODE $ 1-3 READER 5 DATE $ 7-16;
111 1 01JAN2012
111 2 01FEB2012
222 1 01MAR2012
222 2 01APR2012
333 1 01MAY2012
333 2 01JUN2012
DATA R1 (KEEP = CODE READER R1DATE XXX)
R2 (KEEP = CODE READER R2DATE XXX);
IF READER = 1 THEN DO;
XXX = 1;
RENAME DATE = R1DATE;
ELSE IF READER = 2 THEN DO;
XXX = 2;
RENAME DATE = R2DATE;
I just want the DATE variable to be renamed depending on the reader number. I put that XXX variable to check that the condition is being met. And it is. XXX = 1 for R1 and XXX = 2 for R2.
But R1DATE isn't being sent to R1. I get:
WARNING: The variable R1DATE in the DROP, KEEP, or RENAME list has never been referenced.
NOTE: There were 6 observations read from the data set WORK.APPLE.
NOTE: The data set WORK.R1 has 3 observations and 3 variables.
NOTE: The data set WORK.R2 has 3 observations and 4 variables.
It would seem that DATE is being renamed to R1DATE then R2DATE is replacing it. But OUTPUT breaks. I don't need a CONTINUE or LEAVE do I?
Any help is greatly appreciated. I'm sorry for such a dumb question.