Date: Sun, 17 Jul 2005 22:20:46 +0000
Reply-To: toby dunn <tobydunn@HOTMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: toby dunn <tobydunn@HOTMAIL.COM>
Subject: Re: nested macros definitions
In-Reply-To: <dbd3gm$717$1@inews.gazeta.pl>
Content-Type: text/plain; format=flowed
Majkel,
All I can say is this is a bad idea for so many reasons I am not going to
even start. Instead I am going to show you how to do what you want and let
you deal with the headaches.
I put my touch on the macros but that shouldn't be a big deal.
%macro outer(outeryear= ) ;
%local outeryear ;
%macro inner(inneryear=&outeryear) ;
%local inneryear ;
title "Statistics for year &inneryear" ;
%mend inner ;
%inner
%mend outer ;
%outer(outeryear= 2005)
Should do it.
Toby Dunn
From: majkel <caatcher@GAZETA.PL>
Reply-To: majkel <caatcher@GAZETA.PL>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: nested macros definitions
Date: Sun, 17 Jul 2005 10:07:04 +0200
Hello
> While I'm not sure what you are really asking for, would defining the
> macro variable as local accomplish what you want?
Not quite. I would like to be able to execute the %inner macro
beyond the %outer macro.
Let's say I define something like this again:
%macro outer(year);
%macro inner;
title "Statistics for year &year";
%mend inner;
%mend outer;
Then, I execute the %outer macro to compile the %inner macro.
%outer(2005);
Then I execute the %inner macro:
%inner;
and I would like to have the title set for:
"Statistics for year 2005",
but what I get, is:
"Statistics for year &year"
because the &year variable is a local variable of macro %outer.
The problem is, that this variable is resolved not during compilation time
when executing
%outer(2005) - only then the &year variable is known an equals 2005. Only
when I invoke
%inner; the variable &year is looked for, but it is not known in this
context. The problem is, how to
replace &year for 2005 during this: %outer(2005), so that the phrase &year
does not appear any more
in the body of a macro, when executing this: %inner.
Thanks for an interest.
best regards,
michael