经hopewell大大的指点
我在SAS HELP中找到了星星点点的原文
How the Macro Processor Evaluates Logical Expressions
......
A special case of a character operand is an operand that
looks numeric but contains a period character. If you use an operand with a period character in an expression,
both operands are compared as character values. This can lead to unexpected results.
......
Because the %IF-THEN statement in the COMPNUM macro uses
integer evaluation, it
does not convert the operands with decimal points to numeric values. The operands are
compared as character strings using the host sort sequence, which is the comparison of characters with smallest-to-largest values.
原文以
%macro compnum(first,second);
%if &first>&second %then %put &first is greater than &second;
%else %if &first=&second %then %put &first equals &second;
%else %put &first is less than &second;
%mend compnum;
调用
%compnum(10,2.0)
出结果
10 is less than 2.0
解释这个现象,应该和楼主的意思是一致的
附上hopewell大大的指点,sas support上的:
All parts of the macro language that evaluate expressions (for example, %IF and %DO statements) call %EVAL to evaluate the condition. For a complete discussion of how macro expressions are evaluated, see Macro Expressions.
http://support.sas.com/documentation/cdl/en/mcrolref/61885/HTML/default/viewer.htm#a000208971.htm