LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (November 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 10 Nov 2000 10:13:03 -0800
Reply-To:     "Terjeson, Mark" <TERJEMW@DSHS.WA.GOV>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Terjeson, Mark" <TERJEMW@DSHS.WA.GOV>
Subject:      Re: How to convert all variable names into upper cases?
Comments: To: Victor Kamensky <kamensky@AECOM.YU.EDU>
Content-Type: text/plain; charset="iso-8859-1"

Hi Victor,

First off, there's nothing wrong with "working" code. Your macro indeed does the job.

I'm not sure what all characteristics you're looking for, but here's one alternative:

option VALIDVARNAME=UPCASE;

This command immediately converts, not only field names but dataset names as well, for all previously opened datasets and subsequent datasets via the sashelp.vcolumn table. Which means, while your session is open, all existing datasets look and process like they were upper (even though they are still stored on disk as they were previously) and any newly written datasets will be stored as upper.

example:

libname ccc 'c:\temp'; data ccc.test; * currently stored on disk as mixed case ; AAA = 1; bbb = 2; Ccc = 3; run;

option VALIDVARNAME=UPCASE;

data ccc.test2; * will store on disk as upper ; set ccc.test; run;

Hope this is helpful, Mark Terjeson Washington State Department of Social and Health Services Division of Research and Data Analysis (RDA) mailto:terjemw@dshs.wa.gov

-----Original Message----- From: Victor Kamensky [mailto:kamensky@AECOM.YU.EDU] Sent: Friday, November 10, 2000 9:36 AM To: SAS-L@LISTSERV.UGA.EDU Subject: How to convert all variable names into upper cases?

Hi,SAS-L-ers! a). The problem. (V8). Variable names can be in uppercase and in lowercase. Sometimes alphabetical order in proc contents is desired. How to convert all variable names into upper cases? b) My quick tested solution:

%macro upvar(dataset); proc contents noprint data=&dataset out=_c_(keep=name);run; %let nobs=0; data _c_; set _c_; length upname $ 32; upname=upcase(name); if upname^=name; call symput('nobs','1'); run; %if &nobs > 0 %then %do ; data _null_; set _c_ end=last; if _N_=1 then call execute("data &dataset; set &dataset; rename"); call execute(name||'='||upname); if last then call execute("; run;"); run; %end; %mend upvar;

c) I understand my solution is old-fashioned. Surely someone can come with a modern solution. But will it be simpler? Or (and) shorter? Victor Kamensky Programmer Albert Einstein College of Medicine


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