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 09:10:36 -0800
Reply-To:     fred <xkrim3@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         fred <xkrim3@HOTMAIL.COM>
Organization: http://groups.google.com/
Subject:      Re: * macro to rename variables *
Content-Type: text/plain; charset=ISO-8859-1

Loading the variables into an array and using vname to extract the variable names. Then pumping the names into a proc datasets statement using call execute. Very very neat.

Thanks for adding another gem to my treasure trove. As you can see, I am easily excitable when it comes to learning, especially since I am starting from ground zero. This is fun.

WHITLOI1@WESTAT.COM (Ian Whitlock) wrote in message news:<08B08C9FA5EBD311A2CC009027D5BF8102E2B4C5@remailnt2-re01.westat.com>... > Fred, > > Here is another answer using CALL EXECUTE as the primary tool. > > %let class=alpha ; > > /* test data */ > data new_&class ; > retain var1-var250 0 ; > do obs = 1 to 50000 ; > output ; > end ; > retain var1-var2 0 ; > run ; > > data _null_ ; > set new_&class ( obs = 1 ) ; > array __nums (*) _numeric_ ; > call execute ( "proc datasets lib = work ; modify new_&class ; rename " ) > ; > do __i = 1 to dim ( __nums ) ; > call execute ( trim(vname(__nums[__i])) || "=" > || trim(vname(__nums[__i])) || "_&class" ) ; > end ; > > call execute ( "; label " ) ; > do __i = 1 to dim ( __nums ) ; > call execute ( trim(vname(__nums[__i])) || "_&class=" > || quote(trim(vname(__nums[__i]))) ) ; > end ; > call execute ( ";run;quit;" ) ; > run ; > > proc contents data = new_&class ; > run ; > > IanWhitlock@westat.com >


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