Date: Mon, 2 Sep 1996 15:02:08 -0400
Reply-To: Patricia Flickner <pflick@OP.NET>
Sender: "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From: Patricia Flickner <pflick@OP.NET>
Organization: Flickner Enterprises
Subject: Re: Macro question
Stephen Hiemstra wrote:
>
> I would like to write a macro to call and increment another macro as follows:
>
> %MACRO CALLER( int_YY_FROM, int_YY_TO );
> %LOCAL k;
>
> %MACRO CALLEE( YY );
>
> DATA ww.nabk&YY;
> SET ww.nabk&YY;
> **Do more stuff**;
> RUN;
>
> %MEND CALLEE;
>
> %DO k = &int_YY_FROM %TO &int_YY_TO; CALLEE( %k ); %END;
>
> %MEND CALLER;
>
> %CALLER( 85, 95 );
>
> This example failed for two reasons. First, my variables passed to
> the %DO LOOP did not appears as integers to the loop, in spite of my
> obvious passing of integers in the calling routine. Second, the
> call to CALLEE failed because %k was not passed literally as %k and
> not as a string.
>
> Can someone strengthen out the syntax here for me? I have been
> getting lost in the MACRO guide on this one.
>
> Stephen
Stephen, in your example you are creating another macro but not calling
it. Calling the first macro only allows for you to use the second -- it
doesn't actually execute the macro until you say %callee(yyvar);
If you're actually wanting to create 11 data steps, an easier way is to
do this instead:
%MACRO CALLER( int_YY_FROM, int_YY_TO );
%LOCAL k;
%do x = &int_yy_from %to &int_yy_to;
DATA ww.nabk&x;
SET ww.nabk&YY;
**Do more stuff**;
RUN;
%END;
%MEND CALLER;
If you want to keep your macro the way it is, you just forgot to use a
'%' before "calleee".
Pat
|