Date: Fri, 6 Dec 2002 04:58:41 GMT
Reply-To: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Richard A. DeVenezia" <radevenz@IX.NETCOM.COM>
Organization: EarthLink Inc. -- http://www.EarthLink.net
Subject: Re: tip macro function SymChk
"Ian Whitlock" <WHITLOI1@WESTAT.COM> wrote in message
> I assume you lost the formatting and introduced the mistakes in Art's
> version of the SYMCHK macro. The problem with both versions is the
> messages produced in the log when the macro variable does not exist.
> Since you were nice enough to give the link to the SI solution to this
> problem, I took a look. Thanks.
> Now one can say the macro is in a FAQ list and thus it need not meet high
> standards. Or one can ask, doesn't SI have a responsibility to promote
> standards in their public code?
> The first thing to hit me was no comment that the variables I, OB, DSID,
> etc. would always test as being present.
> Second the %LOCAL list is missing more variables than it includes. Then
> began looking at the code more carefully. A lot of stuff is done in the
> loop that should be done outside the loop.
> How should name conflicts be resolved? SCOPE should be used to eliminate
> variable names in CHECK.
> What about the local problem in general? I think it would be good to
> develop the habit of using _abc_ (where a,b, and c are some letters or
> and more chars may be used when appropriate) as a preface to all local
> variables. I suggest that the SAS Institute should claim and use _SAS_.
> The macro I present below was written following that rule. (I use _IW_
> the macro name (possibly abbreviated) enclosed in underscores when I am
> being careful.)
> Now I suggest that
> %local _abc_: ;
> should be allowed to declare all variables beginning with _ABC_ to be
> From my point of view this is a step backward in standards because I
> strongly that each local variable should be made explicit when possible.
> However, I would rather see the suggestion adopted and used than simply
> the %LOCAL statement ignored.
> Here is the macro and tests.
> %macro check(_sas_mvar);
> %* Return yes when macro variable &_sas_mvar exists and no otherwise.
> Note that variables in the %LOCAL statement will always
> return yes.
> %local _sas_i _sas_tmp _sas_dsid _sas_num _sas_val _sas_ob
> %let _sas_dsid=%sysfunc(open(sashelp.vmacro));
I have used this approach in
except I use a where clause in the open (), which can lead to NOTES in the
log in certain cases.
Richard A. DeVenezia