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 (December 2005, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Tue, 13 Dec 2005 09:50:51 +1100
Reply-To:   Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Sender:   "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:   Scott Bass <usenet739_yahoo_com_au@ALFREDO.CC.UGA.EDU>
Subject:   Re: Mod function not working in macro
Comments:   To: sas-l@uga.edu

Your macro will resolve at compile time, generating SAS code which will then get executed. The mod function is a data step function that executes at runtime. So you're mixing compile time code (macro) with runtime code (mod), which would causing a timing error even if it did compile.

However, you can achieve what you want using %sysfunc:

%macro foo; %do i=1 %to 10; %put &i %sysfunc(mod(&i,2)); %end; %mend; %foo;

HTH, Scott

P.S.: You may want to post more details of what you're doing in cause some ODS guru suggests an alternative, non-macro approach.

"David Ryerson" <ryersond@YAHOO.COM> wrote in message news:20051212215759.73852.qmail@web60819.mail.yahoo.com... >I have a macro that either does or doesn't start a new > page based on the value of a macro variable. This is > working well to put exactly two tables on every page > but I'm wondering why I can't use the mod function in > my macro. The code that is giving me an error is: > > (ods rtf...) > %macro report; > %do i = 1 %to &dsglobal; > > %if mod(&i,2)=0 %then %do; /*problem*/ > ods rtf startpage=no; > %end; > %else %do; > ods rtf startpage=now; > %end; > (more code) > %mend; > > This returns the error: > > ERROR: Required operator not found in expression: > mod(&i,2)=0 > > > The less elegant code that does work is: > > (ods rtf...) > %macro report; > %do i = 1 %to &dsglobal; > > %if &i=2 or &i=4 or &i=6 or &i=8 %then %do; /*OK*/ > ods rtf startpage=no; > %end; > %else %do; > ods rtf startpage=now; > %end; > (more code) > %mend; > > Am I using the mod function incorrectly? Is there a > reason why I can't use it in macro code as I am? > > As always, any help is much appreciated. > > David Ryerson > > > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com


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