Date: Fri, 4 May 2007 12:03:51 -0700
Reply-To: "Pardee, Roy" <pardee.r@GHC.ORG>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Pardee, Roy" <pardee.r@GHC.ORG>
Subject: Macro arithmetic problem with %eval() & %sysevalf()
Content-Type: text/plain; charset="us-ascii"
Hey All,
I've got a program in which I want to programmatically set the number of
OUTOBS in proc sql, based on two macro variables. But I'm getting
unexpected errors--in particular on the code below I get the message
"ERROR: A character operand was found in the %EVAL function or %IF
condition where a numeric operand is required. The condition was: 10 +
2.5".
Here's a little sample that demonstrates the problem:
* =========================== ;
%macro test(NumNetwork = 10) ;
%let dead_margin = .25 ;
proc sql ;
reset outobs = %eval(&NumNetwork + %sysevalf(&NumNetwork *
&dead_margin)) nowarn ;
quit ;
%mend ;
options mprint ;
%test ;
* =========================== ;
I've tried every combination of %eval() & %sysevalf() in there, but have
not been able to get this to work. Do I really have to go through a
datastep to do this calculation? I don't understand that error message
in particular.
Many thanks in advance!
-Roy
Roy Pardee
Research Analyst/Programmer
Group Health Center For Health Studies (Cancer Research Network)
(206) 287-2078
Google Talk: rpardee