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 (April 2001, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 26 Apr 2001 16:19:27 -0400
Reply-To:     Jay Weedon <jweedon@EARTHLINK.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jay Weedon <jweedon@EARTHLINK.NET>
Organization: http://extra.newsguy.com
Subject:      Re: A small SAS tip: Renaming large numbers of variables
Content-Type: text/plain; charset=us-ascii

Oh, I forgot to mention that my original dataset contained only one observation. If there had been many more the log would have grown very long & repetitive! Adding STOP; as the last statement in the data _null_ step would help, I think.

JW

On Thu, 26 Apr 2001 10:47:34 -0400, Jay Weedon <jweedon@earthlink.net> wrote:

>Hi folks, > >I know this type of query comes up here every now & then, and the >solutions I've generally seen involve writing somewhat complex macros. > >I'm sure I'm not the first to stumble over this alternative, but FWIW >here it is. It's suitable for the situation where the new names >resemble the old names except for the last few characters. > >I had a dataset containing hundreds of numeric variables, the names of >which all of which end in the digit "3". My problem was to rename all >these 3s to 1s. > >I've taken the macro route before, but it always seems to take me >quite some time to get it working properly. This time I instead wrote >the following little program: > >data _null_; > set oldset; > array allvar _numeric_; > do over allvar; put allvar= 1. +(-2) allvar= 1. +(-4) '1 '; end; >run; > >and then simply pasting the resulting text from the log into the place >I've marked with an asterisk in a 2nd simple program > >data newset; > set oldset; > rename > * > ; >run; > >Jay Weedon.


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