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 (April 2004, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Mon, 26 Apr 2004 12:30:47 -0400
Reply-To:     Quentin McMullen <quentin_mcmullen@BROWN.EDU>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Quentin McMullen <quentin_mcmullen@BROWN.EDU>
Subject:      Re: symchk: checking for macro variable existance
Comments: To: Ron Fehd <rjf2@CDC.GOV>

On Thu, 22 Apr 2004 13:36:36 -0400, Fehd, Ronald J. (PHPPO) <rjf2@CDC.GOV> wrote:

>A Concerned Reader pointedly asks: > >> don't you want to upcase name in your where statement? > > /*SymChkIf SymbolCheck If exist ...*/ >%MACRO SymChkIf(Name); >%local Boolean DsId RC ; >%let Boolean = 0;%*default:false; >%let DsId = %sysfunc(open(SAShelp.vMacro >(where = (name = "%UPCASE(&Name)")))); > >i.e.: >(where = (upcase(name) = "%UPCASE(&Name)")))); > >which prompted a question to TechSupport: > >I want to know whether name of the macro variables in > SAShelp.vMacro.Name >or Dictionary.Macro.Name >will always be upcase. > >The macro had >%let DsId = %sysfunc(open(SAShelp.vMacro >(where = (name = "%UPCASE(&Name)")))); > >and the question was >-- with regard to defensive programming -- >whether this was more robust: >(where = (upcase(name) = "%UPCASE(&Name)")))); > >TechSupport replied: > >> I cannot guarantee the future, >> but at this point in time, >> yes they are stored in upper case. >> I do not know of any plans to change that. > >I'm planning to make that change: >no fear for that macro breaking >and a I'll always have a good night's sleep when I remember it. > >Ron Fehd the robust macro maven CDC Atlanta GA USA RJF2@cdc.gov > >Efficiency is intelligent laziness. -David Dunham >... and defensive coding for robustness

Hi Ron et al,

I would agree that revising to upcase(name) sounds like good defensive coding. Would just add that there is a cost to upcasing strings unnecessarily (which I have at times been willing to pay). I believe when you use the upcase() function on the where statement, sas cannot use any available index. So I've seen things slow down a *lot* when using a where statement against a big dictionary table, and adding upcase() in order to be defensive. So there is a cost to weigh against the benefit. In many cases, it's may be worth the cost for the defensive gain (wasn't too long ago that all variable names were upcase, and I'd imagine some macros started breaking when they went to mix case in v7).

Kind Regards, --Quentin


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