【发布时间】:2019-01-09 20:48:26
【问题描述】:
我正在尝试比较宏中的两个数值。 但我不断收到以下消息:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 0.2
ERROR: The %TO value of the %DO I loop is invalid.
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was: 0.05
ERROR: The %BY value of the %DO I loop is invalid.
ERROR: The macro FAIL will stop executing.
我的代码如下:
%macro fail;
%do i=0 %to 0.2 %by 0.05;
data failcrs;
set fail;
if f_p>=input(&i, 8.) then output;
run;
%end;
%mend failcrs;
f_p 是一个数值变量。
我的代码有什么问题?请帮忙。
非常感谢!
【问题讨论】:
-
让这个工作很容易,但代码不合逻辑,可能不是你想要的。如果是测试用例,我想没问题。
-
我没有看到你在哪里比较宏变量?如果要在宏代码中对浮点值进行操作,则需要使用
%sysevalf()而不是宏语句通常使用的隐式%eval()函数调用。%if %sysevalf( &I >= 0.2) %then ... -
谢谢汤姆!我得到了它。另一个宏函数。