Date: Thu, 5 Dec 2002 09:46:26 -0500
Reply-To: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Fehd, Ronald J. (PHPPO)" <rjf2@CDC.GOV>
Subject: Re: macro design and policy
as illustrated in my previous post:
tip macro function SymChk
I see a need to consense upon some programming issues.
Point #1: What is the range of the macro value returned?
Carpenter's SymbolCheck macro returns a string in (YES,NO)
in other code which uses this convention of returned strings
and other authors' code which returns a string in (yes,no)
in order to standardize handling the different UPCASE or lowcase responses
one is required to use the ungainly test:
%IF %substr(%upcase(&yesnoOrYESNO.),1,1) eq 'Y' %THEN
if one uses the convention of having macro functions return boolean values,
which I highly recommend, this test could be reduced to
%IF &ZEROorONE. %THEN
Point #2: How is the value returned?
Carpenter's SymbolCheck macro uses a temporary macro variable
i.e., a %local mvar, YESNO to contain the value.
which he then returns with the phrase: (not statement)
I agree that this is a good example of a simple macro
that calculates a value and then returns it.
Dividing the task up into two steps is correct for illustration.
I highly recommend returning simple values by the convention I illustrate
in my version of SymChk:
%IF <cond> %THEN 0;
which does not require the necessity of using an intermediate %local macro
Ron Fehd the macro maven CDC Atlanta GA USA RJF2@cdc.gov
Repetition reduction enhances elegance!
Repetition reduction furthers finesse!
CLOCK debugging clue#2:
a macro function does not return SAS semicolons