Date: Mon, 26 Apr 2004 10:09:59 -0400
Reply-To: Michael Whitcomb <mwhitcomb@WESLEYAN.EDU>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Michael Whitcomb <mwhitcomb@WESLEYAN.EDU>
Subject: RENAME and KEEP in one data step
Content-Type: text/plain; charset="us-ascii"; format=flowed
A question/curiosity about using the RENAME and KEEP statements in the same
data step. Rather
by accident I discovered that the RENAME statement can follow either the
DATA statement :
data two (RENAME = (oldvar = newvar));
set one;
keep OLDVAR;
run;
or in the SET line:
data two;
set one (rename = (oldvar = newvar ));;
keep NEWVAR;
run;
*But* the location of the RENAME statement determines whether one must
specify the OLDVAR or NEWVAR
in the subsequent KEEP statement. Perhaps this coding is kludge - I am
curious if there is a best practice
for renaming variables and then keeping these variables in the same data
step and why the RENAME can go in
either location but then influences how one KEEPs these variables. Oh,
and please no PROC SQL solutions
because I am doing other computations in this datastep.
TIA,
Michael Whitcomb
|