我有一段代码已经参数化了大约一百个类似但不完全相同的SQL语句,我需要生成我需要的数据。除了where语句之外,参数化工作正常。我传入以下格式的宏字符串:
where PERIOD_LAST_DTTM = '31DEC2017:23:59:59'dt
and myvar1 = 1 and myvar2 < 0
and myvar3 in ('SOME STRING', 'SOME OTHER STRING')
...使用以下语法:
%if %eval(&inn_sel_var. ^= &comp_var2.) %then %do;
&inn_sel_var.
%end;
/ &amp; inn_sel_var是字符串&amp; comp_var2 = NULL /
...但是我收到以下错误:
ERROR: A character operand was found in the %EVAL function or %IF condition where a numeric operand is required. The condition was:
where PERIOD_LAST_DTTM = '31DEC2017:23:59:59'dt and myvar1 = 1 and myvar2 < 0 and myvar3 in ('SOME STRING', 'SOME OTHER STRING')
^= NULL
ERROR: %EVAL function has no expression to evaluate, or %IF statement has no condition.
ERROR: The macro MODEL_CHECKS will stop executing.
...我尝试使用%STR,%SUPERQ,%QUOTE,%BQUOTE,%NRQUOTE,%NRBQUOTE和%UNQUOTE,但我一直在遇到错误。有人可以告诉我需要做什么才能正确地将参数化为哪些参数?
由于
答案 0 :(得分:1)
您需要显示更多程序和/或日志。
但使用%superq()
可以防止%IF
语句中出现此类错误消息。
%if %superq(inn_sel_var) ne %superq(comp_var2) %then &inn_sel_var. ;
当然,INN_SEL_VAR
宏变量的值可能仍会在生成的SAS代码中生成错误。