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 (November 2002, week 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 7 Nov 2002 07:52:28 -0800
Reply-To:     fred <xkrim3@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         fred <xkrim3@HOTMAIL.COM>
Subject:      Re: * macro to rename variables *
Content-Type: text/plain; charset=ISO-8859-1


Yup. I was bulldozing, given my very limited knowledge.

Proc Datasets helps a tonne. THANKS ! Here's my interim solution b4 I figure out the Proc SQL bit:

* simulated data ; %let class=alpha ; data newset_&class ; retain Var1-Var250 0 ; do i=1 to 50000 ; output ; end ; drop i ; run ;

%macro rename1(chgname=chgname, class=&class, name2=name2); proc datasets lib=work nodetails nolist ; modify newset&class ; rename &chgname ; label &name2=&name2 ; run ; quit ; %mEnd rename1 ;

%macro rename2(class=alpha) ; proc contents data=newset_&class out=list_&class (keep=name) noprint ; run ; data name_&class ; set list_&class ; if name not in ('Var2','Var5') then chgname = trim(name)||"="||trim(name)||"_&class" ; * Var2 & Var5 excluded ; if name not in ('Var2','Var5') then name2 = trim(name)||"_&class" ; call execute ('%rename1(chgname='||chgname||",class=_&class"||",name2="||name2||")") ; * rename2 calls rename1 ; run ; %mEnd rename2 ;


WHITLOI1@WESTAT.COM (Ian Whitlock) wrote in message news:<>... > Fred, > > Horror of horrors in macro! Repetition should be wielded like a scalpel not > a sledge hammer. See the archives and search for "rename" any two month > period will probably be enough. > > In short, use PROC SQL with the dictionary files to the names of the > variables and make the macro variables. then use PROC DATASETS to apply the > renames and labels. No data at all should be read! (Unless you need a copy > of the data and then only once.) > > >

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