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 (October 2002, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 17 Oct 2002 16:06:19 -0500
Reply-To:     Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Kevin Myers <KevinMyers@AUSTIN.RR.COM>
Subject:      Re: Determining macro expansion context
Comments: To: Quentin McMullen <QuentinMcMullen@WESTAT.COM>
Content-Type: text/plain; charset="iso-8859-1"

Good catch Quentin. I had to leave my desk for a bit, and just as soon as I walked away, I also realized that this would probably work for Gordon's needs. But you beat me to the punch!

s/KAM

----- Original Message ----- From: "Quentin McMullen" <QuentinMcMullen@WESTAT.COM> Newsgroups: bit.listserv.sas-l To: <SAS-L@LISTSERV.UGA.EDU> Sent: Thursday, October 17, 2002 3:06 PM Subject: Re: Determining macro expansion context

> Buchanan, Gordon [mailto:gordon.buchanan@GMACRFC.COM] asks: > > > > Does anyone know if there is a way for a macro to determine > > the context > > into which it is being expanded. I.e. can a macro tell if it is being > > expanded as part of a data step, within a proc, or in open code? > > > > If there is not such a facility has anyone ever asked SAS for > > it, and what > > was the response? > > > > I would like to write a common error handling macro that > > could be used in a > > data step, within a PROC SQL, and within a PROC IML. > > Currently I have three > > different macros: %error, %data_error, and %iml_error. > > Hi Gordon, > > I haven't played with it before, but it looks like the automatic variable > &sysprocname would be helpful to you. See log below, it returns null in > open code, DATASTEP, or name of the procedure. > > 13777 %put sysprocname=&sysprocname; > sysprocname= > 13778 > 13779 data a; > 13780 %put sysprocname=&sysprocname; > sysprocname=DATASTEP > 13781 run; > 13782 > 13783 proc print; > 13784 %put sysprocname=&sysprocname; > sysprocname=PRINT > 13785 run; > 13786 > 13787 proc iml; > NOTE: IML Ready > 13788 %put sysprocname=&sysprocname; > sysprocname=IML > 13789 quit; > > Hope this helps, > --Quentin


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