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 (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 17:41:43 +0100
Reply-To:     Peter Crawford <peter.crawford@DB.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Peter Crawford <peter.crawford@DB.COM>
Subject:      A small SAS tip: Renaming large numbers of variables
Comments: To: jweedon@earthlink.net
Content-type: text/plain; charset=iso-8859-1

HI Jay That's really smart ! Before, when faced with this kind of problem, I would, from the var window, markblock, copy and then paste the columns into the program editor but that seems to have become far to complex in these gui displaymanager days. Your method's arrival is most timely ! many thanks and Kind Regards Peter Crawford

Datum: 26/04/2001 16:26 An: SAS-L@listserv.uga.edu

Antwort an: jweedon@earthlink.net

Betreff: A small SAS tip: Renaming large numbers of variables Nachrichtentext:

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.

--

Diese E-Mail enthält vertrauliche und/oder rechtlich geschützte Informationen. Wenn Sie nicht der richtige Adressat sind oder diese E-Mail irrtümlich erhalten haben, informieren Sie bitte sofort den Absender und vernichten Sie diese Mail. Das unerlaubte Kopieren sowie die unbefugte Weitergabe dieser Mail ist nicht gestattet.

This e-mail may contain confidential and/or privileged information. If you are not the intended recipient (or have received this e-mail in error) please notify the sender immediately and destroy this e-mail. Any unauthorised copying, disclosure or distribution of the material in this e-mail is strictly forbidden.


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