LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous (more recent) messageNext (less recent) messagePrevious (more recent) in topicNext (less recent) in topicPrevious (more recent) by same authorNext (less recent) by same authorPrevious page (March 2012, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 Mar 2012 21:52:42 +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: Writing Macro Variables to Certain Symbol Tables XXXX
Comments: To: dan.abner99@gmail.com
In-Reply-To:  <CAPRGo-mTxtaiLqcKq-KutJwX3_8=cs7H4817iAzbKypeTAGOqA@mail.gmail.com>
Content-Type: text/plain; charset="Windows-1252"

DEfining a macro within a macro is inefficient and confusing at best..... at worst well we wont go there... All you have to do is define the macro variable you want as local to your outer macro and assign its value in the inner macro. %Macro Outer( XXX = ) ; %Local MyVar ; %Put XXX= &XXX MyVar=&MyVar ; %Macro Inner( YYY = ) ; %Let MyVar = &YYY ; %Mend Inner ;

%Inner( YYY = ABC ) %Put XXX= &XXX MyVar=&MyVar ; %Mend Outer ; %Outer( XXX = 123 )

However, this does fly in the face of information hiding, which is what the two macros should be doing. To put it another way the outer macro should care how the nner macro does its thing and the inner macro should never care how the Outer macro does its thing. A better way to do this is: %Macro Inner( YYY= ) ; %Local MyVar ; %Let MyVar = &YYY ; &YYY %Mend Inner ;

%Macro Outer( XXX = ) ; %Local MyVar ; %Let MyVar = 123 ; %Put XXX=&XXX MyVar=&Myvar ; %Let MyVar = %Inner( YYY = &XXX ) ; %Put XXX=&XXX MyVar=&Myvar ; %Mend Outer ;

%Outer( XXX = ABC )

Toby Dunn

If you get thrown from a horse, you have to get up and get back on, unless you landed on a cactus; then you have to roll around and scream in pain. “Any idiot can face a crisis—it’s day to day living that wears you out” ~ Anton Chekhov

> Date: Mon, 26 Mar 2012 14:22:53 -0400 > From: dan.abner99@GMAIL.COM > Subject: Writing Macro Variables to Certain Symbol Tables XXXX > To: SAS-L@LISTSERV.UGA.EDU > > Hi everyone, > > I have 1 macro program nested within another. How can I write a macro > variable created in the inner macro to the outer macro symbol table > (but NOT the global symbol table)? > > Thanks! > > Dan


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