Date: Fri, 15 Jun 2007 04:45:58 -0700
Reply-To: barry.debenham@TALK21.COM
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: barry.debenham@TALK21.COM
Organization: http://groups.google.com
Subject: Re: loop through string macro variable
In-Reply-To: <1181906339.949515.72110@o61g2000hsh.googlegroups.com>
Content-Type: text/plain; charset="us-ascii"
On 15 Jun, 12:18, Dirk Nachbar <dirk...@googlemail.com> wrote:
> The code below creates "var x11-x21; var y11-y21; var z11-z21;"
> although it want to create "var x11-x21 y11-y21 z11-z21" (prod=10).
> How to get around that. Thanks.
>
> proc summary data=temp;
> class store week;
> var %let j=1;
> %do %while (%scan(&vars, &j, %str( ))> );
> %let var=%scan(&vars, &j, %str( ));
> &var.11-&var.%eval(10+&prod);
> %let j=%eval(&j+1);
> %end;
> output out=tupcdata (where=(_type_=3)) sum= ;
> run;
>
> Dirk
Dirk,
You have put an unwanted semi-colon in the middle of the executable
macro code.
%let and %do are language statements that control the flow of the
code. Whereas the statement
&var.11-&var.%eval(10+&prod);
is resolved every time you go through the loop - so the final semi-
colon is produced on every iteration. Just remove it and place it
after the %end; Viz: %END;;
Or, if you fear that this looks a bit too much like a mistake when you
review your code then use: %end;%str(;)
Regards,
Barry D.
|