LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2012, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
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.
Comments: To: Brian Wallace <brian_c_wallace@YAHOO.COM>
In-Reply-To:  <1328704329.64184.YahooMailClassic@web39402.mail.mud.yahoo.com>
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

http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001225397.htm

another idea ...

data r1(where=(reader eq 1) rename=(date=r1date)) r2(where=(reader eq 2) rename=(date=r2date)); set apple; run;

Mike Zdeb U@Albany School of Public Health One University Place (Room 119) Rensselaer, New York 12144-3456 P/518-402-6479 F/630-604-1475

________________________________________ 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 To: SAS-L@LISTSERV.UGA.EDU 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:

DATA APPLE; INPUT CODE $ 1-3 READER 5 DATE $ 7-16; CARDS; 111 1 01JAN2012 111 2 01FEB2012 222 1 01MAR2012 222 2 01APR2012 333 1 01MAY2012 333 2 01JUN2012 ; RUN;

DATA R1 (KEEP = CODE READER R1DATE XXX) R2 (KEEP = CODE READER R2DATE XXX); SET APPLE; IF READER = 1 THEN DO; XXX = 1; RENAME DATE = R1DATE; OUTPUT R1; END; ELSE IF READER = 2 THEN DO; XXX = 2; RENAME DATE = R2DATE; OUTPUT R2; END; RUN;

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.

Thank you,

Brian Wallace


Back to: Top of message | Previous page | Main SAS-L page