LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (July 2005, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Mon, 18 Jul 2005 04:14:23 -0400
Reply-To:   Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject:   Re: nested macros definitions
Comments:   To: caatcher@GAZETA.PL

Hi Michael,

I think for your problem you don't even need a nested macro definition. Just one macro with varying contents of macro variables will do. Nesting macro definitions only makes sense of you inner macro will have varying contents, based on conditions in the outer macro. See als my example in the (two line) URL: http://listserv.uga.edu/cgi-bin/wa?S2=sas- l&D=1&H=0&O=D&T=1&q=&s=realize+nested&f=&a=july+2005&b=

Regards - Jim. -- Y. (Jim) Groeneveld, MSc., Biostatistician, Vitatron b.v., NL Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign) http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

My computer always teaches me something new I thought I knew already.

[common disclaimer]

On Sun, 17 Jul 2005 00:57:31 +0200, majkel <caatcher@GAZETA.PL> wrote:

>Hello, >I am trying to construct one macro by means of another. What I want to >achieve is to create an inner macro that would be independent from the >macro, by means of which it was created. In this example: > >%macro outer(year); > %macro inner; > title "Statistics for year &year"; > %mend inner; > %inner; >%mend outer; > >%outer(2005); > >everything works fine, as I resolve to the %inner macro within the body of >the %outer macro. When the %inner macro is executed beyond the %outer (and >assuming that there is no other variable called &year), the variable &year >is unknown - which is obvious. > What I am trying to achieve, is to define the body of the inner macro, >so that the &year variable is resolved BEFORE the %inner macro is compiled, >so that the &year variable does not have to be resolved each time, the >%inner macro is executed. > >Another attempt to do that was: > > >%macro outer(year); > %let text=%nrstr(%%macro inner;); > %let text=&text %nrstr(title %"Statistics for year)&year%nrstr(%";); > %let text=&text %nrstr(%%mend;); > &text; >%mend; > >%outer(2005); > > >But it did not work due to compilation errors :(( >Does anyone has any idea how to do that? Is it possible at all?? >I will be very thankful for any help. > >Michael.


Back to: Top of message | Previous page | Main SAS-L page