需要第二双眼睛:
%MACRO FIND_CLOSEST_LIMIT_OR_DEDUCTIBLE(limOrDedOption,limOrDedValue);
%LET numOptions = %Sysfunc(Countw(&limOrDedOption.));
limOrDedSetFlag = 'N';
%DO curLimOrDed = 1 %TO &numOptions.;
IF limOrDedSetFlag = 'N' AND &curLimOrDed = 1 AND &limOrDedValue. <= %Scan(&limOrDedOption.,&curLimOrDed.) THEN DO;
&limOrDedValue. = %Scan(&limOrDedOption,1);
limOrDedSetFlag = 'Y';
END;
IF limOrDedSetFlag = 'N' AND &curLimOrDed. >= 2 THEN DO;
lowerLimOrDed = %Scan(&limOrDedOption,prevLimOrDed, &curLimOrDed. - 1);
upperLimOrDed = %Scan(&limOrDedOption.,&curLimOrDed);
IF &limOrDedValue. < %Scan(&limOrDedOption.,&curLimOrDed) THEN DO;
IF (&limOrDedValue. - lowerLimOrDed)/ (upperLimOrDed - lowerLimOrDed) < 0.5 THEN
&limOrDedValue. = lowerLimOrDed;
ELSE &limOrDedValue. = upperLimOrDed;
limOrDedSetFlag = 'Y';
END;
END;
%END;
IF MISSING(&limOrDedValue.) THEN &limOrDedValue. = 0;
/* DROP lowerLimOrDed upperLimOrDed;*/
%MEND FIND_CLOSEST_LIMIT_OR_DEDUCTIBLE;
收到以下错误:
MPRINT(FIND_CLOSEST_LIMIT_OR_DEDUCTIBLE): IF limOrDedSetFlag = 'N' AND 1 >= 2 THEN DO;
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
prevLimOrDed
ERROR: Argument 2 to macro function %SCAN is not a number.
NOTE 137-205: Line generated by the invoked macro "FIND_CLOSEST_LIMIT_OR_DEDUCTIBLE".
104 DO; lowerLimOrDed = %Scan(&limOrDedOption,prevLimOrDed, &curLimOrDed. - 1); upperLimOrDed =
_
22
104 ! %Scan(&limOrDedOption.,&curLimOrDed); IF &limOrDedValue. < %Scan(&limOrDedOption.,&curLimOrDed) THEN DO; IF
104 ! (&limOrDedValue. - lowerLimOrDed)/ (
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, INPUT, PUT.
看起来 SAS 不喜欢 &curLimOrDed - 1. 有什么帮助吗?
谢谢!