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>
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.
On Thu, 26 Apr 2001 10:47:34 -0400, Jay Weedon <firstname.lastname@example.org>
>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:
> set oldset;
> array allvar _numeric_;
> do over allvar; put allvar= 1. +(-2) allvar= 1. +(-4) '1 '; end;
>and then simply pasting the resulting text from the log into the place
>I've marked with an asterisk in a 2nd simple program
> set oldset;