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
Content-Type: text/plain;
"Ian Whitlock" <WHITLOI1@WESTAT.COM> wrote in message
news:08B08C9FA5EBD311A2CC009027D5BF8102E2B56E@remailnt2-re01.westat.com...
> Ron,
>
> 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
warning
> 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
high
> 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
I
> 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
null
> 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_
or
> 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
local.
>
> From my point of view this is a step backward in standards because I
believe
> strongly that each local variable should be made explicit when possible.
> However, I would rather see the suggestion adopted and used than simply
have
> 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
> _sas_scope
> ;
> %let _sas_dsid=%sysfunc(open(sashelp.vmacro));
...big snip...
I have used this approach in
http://www.devenezia.com/downloads/sas/macros/#existmv
except I use a where clause in the open (), which can lead to NOTES in the
log in certain cases.
--
Richard A. DeVenezia
|