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 (February 1997, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 20 Feb 1997 11:50:46 -0800
Reply-To:     Jean-Pierre Le Cruguel <jean-pierrel@ALGENE.COM>
Sender:       "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:         Jean-Pierre Le Cruguel <jean-pierrel@ALGENE.COM>
Organization: Communications Accessibles Montreal, Quebec Canada
Subject:      Re: changing variable names
Content-Type: text/plain; charset=us-ascii

Nicole Morgan Gibson wrote: > > I have several data files of data collected over a five year period. > These files need to be merged together by id but the variable names do > not change from year to year. Is there any way to efficiently > change the variable names in sas? I am currently using proc datasets > but do I have to type each oldname and newname? Can I use the statement > rename var1-var10=newvar1-newvar10? I'm pretty sure the answer is > no, but can someone suggest a good way to change hundreds of > variable names in an efficient manner? > > Thanks, Nicole

Hi Nicole,

What you need to use is an array statement in each of your datasets before to merge them.

/* year 1 */ DATA one; SET datyear1; ARRAY var{*} var1-var100; ARRAY yr1var{*} yr1var1-yr1var100; DO i = 1 TO DIM(var); yr1var{i} = var{i}; END; KEEP id yr1var1-yr1var100; RUN;

For doing this, your variable names must be sequential (even in several sequences), otherwise you will have to rename them one by one.

JP


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