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 (March 2007, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 31 Mar 2007 18:14:55 -0500
Reply-To:     "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Richard A. DeVenezia" <rdevenezia@WILDBLUE.NET>
Subject:      Re: code challenge: subroutine checks that caller has %local
              mvars to
Comments: To: sas-l@uga.edu

Martin Gregory wrote:

> It looks like sashelp.vmacro is treated like a stack: if you could > rely on that, then you'd know what the calling macro is.

Thediscovery process that supplies the DICTIONARY.MACRO view certainly does appear to deliver information in a stack. But there is no indication of the call stack, which obviously must be known to the macro supervisor. See option MPRINTNEST.

Without documentation stating the view is a stack, I would argue against building a macro library on the potential sandpit it will not be in the future.

Sample of a recursive macro: -------------------------------------------- %macro recurse (n=1);

%if &n > 10 %then %return;

%local MyMacroVar ;

%let MyMacroVar = %sysevalf(&n**2);

title "recurse called with n=&n";

proc print data=sashelp.vmacro; where name like 'MY%'; run;

%recurse (n=%eval(&n+1)) %mend;

options ;

%put %sysfunc(pathname(work));

ods listing close; ods html file="%sysfunc(pathname(work))\recurse-report.html" style=meadow;

%let myMacroVar = CornerStone; %recurse;

%symdel myMacroVar;

ods html close; --------------------------------------------

-- Richard A. DeVenezia http://www.devenezia.com/


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