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 (August 2005, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 30 Aug 2005 12:22:29 -0400
Reply-To:     Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject:      Re: Best practice: check for blank macro parameters
Comments: To: M N <iced_phoenix_news@YAHOO.COM>

Hi Matt,

I mainly use something like: %IF &MacroVar EQ %THEN ....... (or NE instead of EQ)

Surrounding quotes do not make sense as quotes in macro code; they are just part of the character string.

So, if the macro variable to test legitimately may have contents at which the macro program would crash, because of unintended interpretation of that contents, I quote the macro variable (which is generally a better idea) as in: %IF %QUOTE(&MacroVar) EQ %THEN ....... (or NE instead of EQ)

Regards - Jim. -- Y. (Jim) Groeneveld, MSc., Biostatistician, Vitatron b.v., NL Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign) http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

My computer always teaches me something new I thought I knew already.

[common disclaimer]

On Tue, 30 Aug 2005 08:59:49 -0700, m n <iced_phoenix_news@YAHOO.COM> wrote:

>Dear SAS-L, > >For the common practice of checking that required >macro parameters are not blank, different programmers >adopt different approaches: > >* %if &VAR= %then <insert code> >* %if "&VAR"="" %then <insert code> >* %if &VAR=%str() %then <insert code> >* using %superq(), %nrstr, %bquote, %nrbquote, etc in >various ways. > >Etc, etc. > >Is there any consensus among the gurus as to a Best >Practice in this regard (i.e. a method that is quite >likely to work regardless of what users may pass into >the macro)? > >Thanks in advance, >Matt > > > >____________________________________________________ >Start your day with Yahoo! - make it your home page >http://www.yahoo.com/r/hs


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