%let CHECK_DATE = %sysfunc(SUM(&end_of_period.,1),yymmdd10.);
proc sql;
select * from table1
where Source_Date < input(&CHECK_DATE.,yymmdd10.);
quit;
&amp; CHECK_DATE是一个日期宏,格式为&#39; 2015-12-31&#39;;
Source_Date是SAS日期值。
当我尝试运行此代码时出现此错误。不知道为什么......
_
22
_
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, a numeric constant, a datetime constant,
a missing value, (, +, -, BTRIM, CALCULATED, CASE, EXISTS, INPUT, NOT, PUT, SUBSTRING, TRANSLATE, USER, ^, ~.
ERROR 200-322: The symbol is not recognized and will be ignored.
_
22
76
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, ',', -, /, <, <=, <>, =, >, >=, ?, AND, BETWEEN,
CONTAINS, EQ, EQT, GE, GET, GT, GTT, IN, IS, LE, LET, LIKE, LT, LTT, NE, NET, NOT, NOTIN, OR, ^, ^=, |, ||, ~, ~=.
ERROR 76-322: Syntax error, statement will be ignored.
答案 0 :(得分:2)
我认为这只是因为你没有在你的字符文字中加上你传递给INPUT()
函数的引号。
此代码运行。
data table1;
source_date=date();
format source_date yymmdd10.;
run;
%let end_of_period=%sysfunc(date());
%put &=end_of_period ;
%let CHECK_DATE = %sysfunc(SUM(&end_of_period.,1),yymmdd10.);
%put &=check_date ;
proc sql;
select * from table1
where Source_Date < input("&CHECK_DATE",yymmdd10.)
;
quit;
但不使用&CHECK_DATE
并使用&END_OF_PERIOD
编写where子句会更容易。
proc sql;
select * from table1
where Source_Date < &end_of_period + 1
;
quit;