我正在尝试运行程序,并在Enterprise Guide中提示输入日期。我有提示配置,它在我运行程序时出现。在程序日志的顶部,我得到以下几行,似乎显示提示的宏值正确填充:
7 %LET Processing_Month_end = 30Nov2015;
8 %LET Processing_Month = 01Nov2015;
9 %LET Processing_Month_label = November 2015;
我的问题是如何在我的程序中使用这些宏值作为日期。如果我尝试一个简单的数据步骤:
data dates;
refDate = &Processing_Month;
run;
我收到以下错误:
24 GOPTIONS ACCESSIBLE;
25 data dates;
26 refDate = &Processing_Month;
NOTE: Line generated by the macro variable "PROCESSING_MONTH".
26 01Nov2015
_______
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,
LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
27 run;
如果我尝试使用输入将值格式化为日期:
data dates;
refDate = input(&Processing_Month, date9.);
run;
我得到了类似的错误:
24 GOPTIONS ACCESSIBLE;
25 data dates;
26 refDate = input(&Processing_Month, date9.);
NOTE: Line generated by the macro variable "PROCESSING_MONTH".
26 01Nov2015
_______
22
ERROR 22-322: Syntax error, expecting one of the following: !, !!, &, *, **, +, -, /, <, <=, <>, =, >, ><, >=, AND, EQ, GE, GT, IN,
LE, LT, MAX, MIN, NE, NG, NL, NOTIN, OR, ^=, |, ||, ~=.
27 run;
如果我尝试将宏值包装在日期文字中:
data dates;
refDate = '&Processing_Month'd;
run;
错误:
24 GOPTIONS ACCESSIBLE;
25 data dates;
26 refDate = '&Processing_Month'd;
____________________
77
ERROR: Invalid date/time/datetime constant '&Processing_Month'd.
ERROR 77-185: Invalid number conversion on '&Processing_Month'd.
27 run;
我需要使用哪个语法或函数来使用此提示宏变量才能将其用作sas日期?
答案 0 :(得分:2)
你快到了。日期文字是正确的答案,除了你遗漏了一件事:'&mvar.'
无法解决,只有"&mvar."
会解决。所以切换到双引号和尾随d,你就是对的。
data dates;
refdate = "&processing_month."d;
run;