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 (June 2000, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 9 Jun 2000 10:28:03 +0200
Reply-To:     Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <J.Groeneveld@ITGROUPS.COM>
Subject:      Re: Passing macro argument back to calling program
Comments: To: Josep Roca <ikht1@cc.uab.es>
Content-Type: text/plain; charset="iso-8859-1"

Josep,

Fine that you succeeded in working out my suggestions yourself. Just some additional thoughts though. First of all you may skip the (first) NDAYS macro parameter as such. NDAYS only needs to be a local macro variable inside the macro and is never returned itself. The macro only directly returns its value. Besides local macro variables should rather explicitely be declared LOCAL, because if the outer environment uses a macro variable with the same name then that variable possibly gets changed. By declaring it LOCAL explicitely it will be a unique variable in any case, not interfering with some identically named variable in the calling part of a program.

Secondly and finally, you macro apparently determines which years are leap years. You only apply modulus 4 as the determining algorithm. Are you aware, that e.g. 1900 and 2100 are not leap years? In your algorithm you should rather exclude the century years (dividable by 100) from being leap years with the exception of years dividable by 400.

Regards - Jim. -- Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 senior statistician, P.O. Box 1 fax. +31 412 407 080 head IT department 5350 AA BERGHEM IMRO TRAMARKO: a CRO J.Groeneveld@ITGroups.com the Netherlands in clinical research

My computer does not need me at all, but I can't do without it anymore.

> -----Original Message----- > From: Josep Roca [SMTP:ikht1@cc.uab.es] > Sent: Wednesday, June 07, 2000 7:56 PM > To: Jim Groeneveld > Subject: RE: Passing macro argument back to calling program > > Hi Jim, > > Thanks you very much. This is the code that you propose: > > %macro DAYS(NDAYS, YEAR); > %if %sysfunc(mod(&YEAR, 4))=0 %then %let NDAYS=364; > %else %let NDAYS=365; > %put NDAYS=&NDAYS; > &NDAYS > %mend DAYS; > > data _null_; > NDAYS=%DAYS(NDAYS, 1993); > put NDAYS=; > run; > > > It's work very nice: > > ============================================ > 36 %macro DAYS(NDAYS, YEAR); > 37 %if %sysfunc(mod(&YEAR, 4))=0 %then %let NDAYS=364; > 38 %else %let NDAYS=365; > 39 %put NDAYS=&NDAYS; > 40 &NDAYS > 41 %mend DAYS; > 42 data _null_; > 43 NDAYS=%DAYS(NDAYS, 1993); > NDAYS=365 > 44 put NDAYS=; > 45 run; > > NDAYS=365 > NOTE: DATA statement used: > real time 0.00 seconds > ============================================ > > > > Thanks for your time. > > > Josep, > > > > Either you have to define your macro variable NDAYS GLOBAL or you should > > rewrite your macro, containing only macro statements, no data step > > statements. Use %SYSFUNC where necessary (for MOD), add percent signs > before > > IF, ELSE and THEN, replace CALL SYMPUT by %LET. Finally just _name_ > &NDAYS > > (without a final semicolon). In your calling program the macro call then > > returns your desired value (like some sort of a macro function) > directly. If > > this is not clear, call me and I will work it out for you the day after > > tomorrow. > > > > Regards - Jim. > > -- > > Y. (Jim) Groeneveld, MSc IMRO TRAMARKO tel. +31 412 407 070 > > senior statistician, P.O. Box 1 fax. +31 412 407 080 > > head IT department 5350 AA BERGHEM IMRO TRAMARKO: a CRO > > J.Groeneveld@ITGroups.com the Netherlands in clinical research > > > > My computer does not need me at all, but I can't do without it anymore. > > > > ---------------- > Josep Roca MD, MPH > > Associate Professor > Epidemiology Unit > Dept of Preventive Medicine > Hospital Universitari "Germans Trias i Pujol" > Autonomous University of Barcelona > Ctra. del Canyet s/n, > E-08916 Badalona, Spain > > Tel. +34 93 497 88 82 > FAX: +34 93 497 88 43 > > jroca@ns.hugtip.scs.es


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