Date: Fri, 1 May 2009 09:20:53 -0500
Reply-To: "./ ADD NAME=Data _null_;" <iebupdte@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "./ ADD NAME=Data _null_;" <iebupdte@GMAIL.COM>
Subject: Re: how to upcase varible names in dataset
In-Reply-To: <002601c9ca4e$ec2fb860$c48f2920$@net>
Content-Type: text/plain; charset=ISO-8859-1
On 5/1/09, Ed Heaton <heatone@comcast.net> wrote:
>
> My final comment is the rhetorical question "Why would you want to make
> your variable names more difficult to read by upper-casing them?"
Exactly! Why do you want this?
However assuming the OP really wants to do this and did not mean "how
to I upcase all the VALUES of the character variables?", it should be
noted that the META data method propose using PROC DATASETS needs a
small qualification. The rename statement in PROC DATASETS works
differently than you might expect.
old-name=new-name
changes the name of a variable in the data set specified in the MODIFY
statement. old-name must be a variable that already exists in the data
set. new-name cannot be the name of a variable that already exists in
the data set or the name of an index, and the new name must be a valid
SAS name.
Therefore if a variable already exists "D" and you try to rename to
"D" you get an error.
58914 data low;
58915 retain a b c D;
58916 stop;
58917 call missing(of _all_);
58918 run;
58919 proc datasets nolist;
58920 modify low;
58921 rename d=D;
ERROR: Variable D already exists on file WORK.LOW.
58922 run;
If you are willing to recreate the data set using a data step then the
VALIDVARNAME option could be useful alternative to the RETAIN method
proposed by Ed..
data low;
retain a b c D;
stop;
call missing(of _all_);
run;
options validvarname=upcase;
data low;
set low;
run;
options validvarname=v7;
proc contents data=low;
run;