Date: Wed, 11 Jul 2007 22:47:24 -0400
Reply-To: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Howard Schreier <hs AT dc-sug DOT org>" <nospam@HOWLES.COM>
Subject: Re: rename in macro
On Tue, 10 Jul 2007 07:22:50 -0700, Dirk Nachbar <dirknbr@GOOGLEMAIL.COM> wrote:
>Dear all
>
>Within a macro I want to rename &num_vars variables using the
>substring function, thereby exluding the ending p&i. Unfortunately SAS
>complains about the substr, although the mprint looks ok. Why??
>
>
>data csv&i;
> set lib1.promo (keep=company week &mvar);
> %do j=1 %to &num_vars;
> rename &&var&j=substr(&&var&j,1,index(&&var&j,"p&i")-1);
> %end;
> run;
>
>Dirk
I don't think anyone has explained *why* this did not work. It generates
RENAME statements which have *expressions* rather than simple names
following the equal sign. That's not allowed, whether generated by a macroor
hard-coded.
|