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 1)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 7 Jun 2000 18:32:36 +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 <ikht1@CC.UAB.ES>
Content-Type: text/plain

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.

> -----Original Message----- > From: Josep [SMTP:ikht1@CC.UAB.ES] > Sent: Wednesday, June 07, 2000 6:18 PM > To: SAS-L@LISTSERV.UGA.EDU > Subject: Passing macro argument back to calling program > > Dear fellow SAS users, > > I should be grateful if anyone would help me with the following: > > I whish to write a macro that computes, for instance, the number of the > days in the year, like this: > > %macro DAYS(YEAR=, NDAYS=); > data _null_; > if (mod(&YEAR, 4))=0 then call symput("NDAYS", "366"); > else call symput("NDAYS", "365"); > run; > %put NDAYS=&NDAYS; > %mend DAYS; > > %DAYS(YEAR=1999, NDAYS=); > %put NDAYS=&NDAYS; > > When I submit this code, I got the error (SAS 8 / Win98): > > ================================================================ > NOTE: SAS initialization used: > real time 20.65 seconds > > 1 %macro DAYS(YEAR=, NDAYS=); > 2 data _null_; > 3 if (mod(&YEAR, 4))=0 then call symput("NDAYS", "366"); > 4 else call symput("NDAYS", "365"); > 5 run; > 6 %put NDAYS=&NDAYS; > 7 %mend DAYS; > 8 > 9 %DAYS(YEAR=1999, NDAYS=); > > NOTE: DATA statement used: > real time 1.53 seconds > > > NDAYS=365 > WARNING: Apparent symbolic reference NDAYS not resolved. > 10 %put NDAYS=&NDAYS; > NDAYS=&NDAYS > ================================================================ > > > I do not want to make global "NDAYS". How I can pass the value of the > macro variable NDAYS to the calling programs? > > Thanks for your patience, if I am missing something obvious. > > ---------------- > Josep Roca > Epidemiology Unit > Hospital Universitari "Germans Trias i Pujol" > Ctra. del Canyet s/n, > E-08916 Badalona, Spain


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