Date: Fri, 9 Feb 2001 01:31:19 -0500
Reply-To: "David L. Ward" <dward@INTERNEXT-INC.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "David L. Ward" <dward@INTERNEXT-INC.COM>
Subject: Re: Determining the existence of a macro variable
Content-Type: text/plain; charset="iso-8859-1"
You can check if a macro variable has been defined by checking the
dictionary.macro or sashelp.vmacro view. Here's a macro to do it in pure
macro code:
%macro mvscope (_var);
/** OPEN THE VMACRO VIEW WHICH CONTAINS INFO ABOUT MACOR VARS **/
%let dsid=%sysfunc(open(sashelp.vmacro (where=(name="%upcase(&_var)"))));
/** FETCH A RECORD INTO THE PDV IF IT EXISTS **/
%let rc=%sysfunc(fetch(&dsid));
/** RETURN VARNUM 1, THE SCOPE **/
%sysfunc(getvarc(&dsid,1))
/** CLOSE THE VIEW **/
%let rc=%sysfunc(close(&dsid));
%mend;
Example:
%if %mvscope(var1)=GLOBAL %then %do;
%end;
HTH
David Ward
---------------------
I want to conditionally perform some action in a macro
based on the existence of a macro variable being passed
through the Application Dispatcher. Is there some
straight-forward way of determining the existence of
a macro variable? Any assistance would be appreciated.
Cheers,
Jack Cooper
------------------------------------
President
InterNext, Inc.
Software for the Internet Generation
------------------------------------
|