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 (June 2011, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 17 Jun 2011 13:53:23 -0400
Reply-To:     Quentin McMullen <qmcmullen.sas@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Quentin McMullen <qmcmullen.sas@GMAIL.COM>
Subject:      macro determine name of calling macro
Content-Type: text/plain; charset=ISO-8859-1

Hi All,

Is it possible to have a helper macro determine the name of the macro that it is helping (i.e. determine the name of the macro that invoked it)?

I want to have something like:

%macro inner(dummy); %put Macro Inner was called by: &calledby; %mend inner;

%macro outer(dummy); %inner() %mend outer;

And have it return: Macro Inner was called by: OUTER

I had thought I could come close to what I want with:

%macro inner(calledby=); %put Macro Inner was called by: &calledby; %mend inner;

%macro outer(dummy); %inner(calledby=&sysmacroname) %mend outer;

%outer() But that returns: Macro Inner was called by: INNER

So apparently &sysmacroname is updated as soon as a macro is invoked, even before the parameters are passed to it.

In the past I have resorted to: %macro outer(dummy); %inner(calledby=outer) %mend outer;

But was wondering if I could save myself a few keystrokes, and have %inner figure out who it was called by, rather than having to tell %inner who is calling it.

Obviously SAS knows that %inner was called by %outer, and it can display this information in the log if options MPRINTNEST is on. But can I get this information?

Thanks (and happy Friday), --Quentin


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