|
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.
|