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 (July 2008, week 5)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 29 Jul 2008 21:52:07 -0400
Reply-To:     "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Howard Schreier <hs AT dc-sug DOT org>"
              <schreier.junk.mail@GMAIL.COM>
Subject:      Re: tip: Macro Design Checklist

Seems to be half and half. COUNTC is in 9.1.3 doc (http://support.sas.com/onlinedoc/913/getDoc/en/lrdict.hlp/a002260840.htm). COUNTW appears in the What's New part of 9.2 doc (http://support.sas.com/documentation/cdl/en/whatsnew/61982/HTML/default/lrdictwhatsnew902.htm).

On Tue, 29 Jul 2008 20:01:27 -0400, Bucher Scott <SBucher@SCHOOLS.NYC.GOV> wrote:

>Thanks. They seem to be missing from the SAS 9.1.3 language dictionary. > >Scott Bucher > >-----Original Message----- >From: toby dunn [mailto:tobydunn@hotmail.com] >Sent: Tuesday, July 29, 2008 8:00 PM >To: Bucher Scott; sas-l@listserv.uga.edu >Subject: RE: tip: Macro Design Checklist > > >Scott , > >CountW and CountC is available in 9.1.3 > > >Toby Dunn > >"Don't bail. The best gold is at the bottom of barrels of crap." >Randy Pausch > >"Be prepared. Luck is where preparation meets opportunity." >Randy Pausch > > >> Date: Tue, 29 Jul 2008 11:07:21 -0400 >> From: SBucher@SCHOOLS.NYC.GOV >> Subject: Re: tip: Macro Design Checklist >> To: SAS-L@LISTSERV.UGA.EDU >> >> Thanks. I think countW is new to 9.2, which I don't anticipate getting >> it anytime soon. I am aware of the approach you present, but >personally >> I find %wordcount simpler to read and understand (which is as good a >> reason to use a macro as any), especially when nesting loops like >this. >> Like the broader question of named v. positional parameter, use of the >> '.' suffix, etc. at some point it boils down to context and taste. >> >> -Scott >> >> -----Original Message----- >> From: data _null_, [mailto:datanull@gmail.com] >> Sent: Tuesday, July 29, 2008 10:40 AM >> To: Bucher Scott >> Cc: SAS-L@listserv.uga.edu >> Subject: Re: tip: Macro Design Checklist >> >> I thought you might say that, so only reason you counted the words was >> to be about to write %DO I = 1 %TO (calculated value) which seem >> pointless to me. >> >> Although nowadays I prefer to avoid this type of macro coding >> altogether, it does have some utility. A little bit of restructuring >> and you have code that does not rely on a macro you don't need. >> >> 1 %macro NotUsingWordsMacro(seasons=summer spring fall winter); >> 2 %local i w; >> 3 %let i = %eval(&i + 1); >> 4 %let w = %scan(&seasons,&i,%str( )); >> 5 %do %while(%superQ(w) ne); >> 6 %PUT NOTE: Processing the &i.th word(&w); >> 7 %let i = %eval(&i + 1); >> 8 %let w = %scan(&seasons,&i,%str( )); >> 9 %end; >> 10 %put NOTE: It doesn%str(%')t really matter but the list has >> %eval(&i-1) words; >> 11 %mend notUsingWordsMacro; >> 12 >> 13 %notUsingWordsMacro; >> NOTE: Processing the 1th word(summer) >> NOTE: Processing the 2th word(spring) >> NOTE: Processing the 3th word(fall) >> NOTE: Processing the 4th word(winter) >> NOTE: It doesn't really matter but the list has 4 words >> >> For the very rare case where the number of words is needed just code. >> >> %sysfunc(countW( >> >> >> On 7/29/08, Bucher Scott wrote: >>> For looping through a list of items, i.e.; >>> >>> %let seasons = summer spring fall winter; %do I = 1 %to >>> %wordcount(&seasons); >>> %let season = %scan(&seasons, &i); >>> >>> %end; >>> >>> >>> -Scott >>> >>> -----Original Message----- >>> From: data _null_, [mailto:datanull@gmail.com] >>> Sent: Tuesday, July 29, 2008 10:05 AM >>> To: Bucher Scott >>> Cc: SAS-L@listserv.uga.edu >>> Subject: Re: tip: Macro Design Checklist >>> >>> Why would you need a macro to count words? >>> >>> On 7/29/08, Bucher Scott wrote: >>>> I use positional parameters with macro functions that I use >>>> frequently >>> >>>> and that have arguments that are few and relatively intutitive, e.g. >>>> %wordcount(). If the macro functions has more than 3 arguments, I >>>> use a combination of positional parameters and keyword parameters >>>> with default values. I think the examples cited within the sasautos >>>> library >>> >>>> were also macro functions. >>>> >>>> Regards, >>>> Scott Bucher >>>> >>>> >>>> -----Original Message----- >>>> From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of >> >>>> Fehd, Ronald J. (CDC/CCHIS/NCPHI) >>>> Sent: Tuesday, July 29, 2008 9:05 AM >>>> To: SAS-L@LISTSERV.UGA.EDU >>>> Subject: Re: tip: Macro Design Checklist >>>> >>>>> From: RolandRB >>>>> >>>>> On Jul 28, 10:06 pm, r...@CDC.GOV ("Fehd, Ronald J. (CDC/CCHIS/ >>>>> NCPHI)") wrote: >>>>>> I have updated my Macro Design Checklist page >>>>>> >>>>>> http://www.sascommunity.org/wiki/Macro_Design_Issues_Checklist >>>>> >>>>> Your first tip is "always use named parameters". >>>> >>>>> This is a bad general tip to give >>>> >>>> My 20 years experience says otherwise. >>>> >>>>> as it depends on the circumstances. >>>> >>>> imnsho, those circumstances are usually that the macro is in a >>> program. >>>> >>>> \begin{quote} >>>> Note: These recommendations are for project and site macros, i.e. >>>> macros not in a program, but in separate files. >>>> \end{quote} >>>> >>>>> The SAS Institute >>>>> itself does not follow this recommendation. >>>> >>>> yes, I know. >>>> From my perspective on the HelpDesk >>>> SAS Institute creates more problems for itself and its customers by >>>> publishing Reeeeally! Bad Examples both in OnLine Doc, paper >>>> manuals, and training courses. >>>> >>>>> Check out the %trim and >>>>> %left macros that they distribute with their sasautos library. >>>> >>>> There are 500 macros provided in 300 files in 13 folders in the >>>> sasautos library. >>>> The only thing that I would recommend about them is that they have a >> >>>> fairly consistent header for their documentation. >>>> >>>> Ron Fehd the documentation maven >>>> and the macro maven CDC Atlanta GA USA RJF2 at cdc dot gov >>>> >>> > >_________________________________________________________________ >Stay in touch when you're away with Windows Live Messenger. >http://www.windowslive.com/messenger/overview.html?ocid=TXT_TAGLM_WL_mes >senger2_072008


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