提示:日期,%Sysfunc(year(&myvar.));
Prompt: Date, %Sysfunc(year(&myvar.));
我有一个按月生成报告的 SAS EG 7.1 程序。旧流程是非常手动的,除其他事项外,要求用户使用当前月末 (Date9.) 更新宏变量 (&date.)。
%let Date = '28feb2018'd; /* <--- Input the date to be reported */
/* Generate the year and the month based on the input date */
%let year = %sysfunc(year(&date.));
%let month = %sysfunc(month(&date.));
&年(4 位)和&月。 (1 位或 2 位数字,具体取决于月份)稍后在代码中用作文件名的组成部分以获取当前月份的表格:
FROM lib.great_table_loc_&year._&month.;
我试图通过提示用户选择当前月末日期来使程序动态化。
提示正在运行,并输出 date9。格式。
然后我尝试使用宏变量 &Prompt_date。在 %sysfunc 中:
%let Date = '&prompt_date.';
%let year = %sysfunc(year(&prompt_date.));
%let month = %sysfunc(month(&prompt_date.));
当我执行时,我收到以下错误消息:
1)
35 %let year = %sysfunc(year(&prompt_date.));
ERROR: Argument 1 to function YEAR referenced by the %SYSFUNC or
%QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC
argument list. Execution of %SYSCALL statement or %SYSFUNC
or %QSYSFUNC function reference is terminated.
36 %let month = %sysfunc(month(&prompt_date.));
ERROR: Argument 1 to function MONTH referenced by the %SYSFUNC or
%QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC
argument list. Execution of %SYSCALL statement or %SYSFUNC
or %QSYSFUNC function reference is terminated.
2)
118 lib.great_table_loc_._.
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, ;,
(, ',', ANSIMISS, AS, CROSS, EXCEPT, FULL, GROUP, HAVING,
INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER,
RIGHT, UNION, WHERE.
ERROR 200-322: The symbol is not recognized and will be ignored.
我试过为月份和年份创建一个单独的字段,格式为 YYMMN6。输入 &prompt_date。然后 put(,n.) 使值成为数字 - 仍然没有。
有没有人遇到过类似的问题?
关于如何获得我想要的东西的任何提示?
谢谢!
你有:
%let Date = '&prompt_date.';
%let year = %sysfunc(year(&prompt_date.));
%let month = %sysfunc(month(&prompt_date.));
两个问题。
- 您分配了 &Date 但未使用它。
- 提示日期是 DDMONYYYY(日期 9.)。 SAS 会将其视为一个字符串。您需要引号和
d
才能成为日期。
尝试
%let year = %sysfunc(year("&prompt_date."d));
%let month = %sysfunc(month("&prompt_date."d));
我有一个按月生成报告的 SAS EG 7.1 程序。旧流程是非常手动的,除其他事项外,要求用户使用当前月末 (Date9.) 更新宏变量 (&date.)。
%let Date = '28feb2018'd; /* <--- Input the date to be reported */
/* Generate the year and the month based on the input date */
%let year = %sysfunc(year(&date.));
%let month = %sysfunc(month(&date.));
&年(4 位)和&月。 (1 位或 2 位数字,具体取决于月份)稍后在代码中用作文件名的组成部分以获取当前月份的表格:
FROM lib.great_table_loc_&year._&month.;
我试图通过提示用户选择当前月末日期来使程序动态化。 提示正在运行,并输出 date9。格式。
然后我尝试使用宏变量 &Prompt_date。在 %sysfunc 中:
%let Date = '&prompt_date.';
%let year = %sysfunc(year(&prompt_date.));
%let month = %sysfunc(month(&prompt_date.));
当我执行时,我收到以下错误消息:
1)
35 %let year = %sysfunc(year(&prompt_date.));
ERROR: Argument 1 to function YEAR referenced by the %SYSFUNC or
%QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC
argument list. Execution of %SYSCALL statement or %SYSFUNC
or %QSYSFUNC function reference is terminated.
36 %let month = %sysfunc(month(&prompt_date.));
ERROR: Argument 1 to function MONTH referenced by the %SYSFUNC or
%QSYSFUNC macro function is not a number.
ERROR: Invalid arguments detected in %SYSCALL, %SYSFUNC, or %QSYSFUNC
argument list. Execution of %SYSCALL statement or %SYSFUNC
or %QSYSFUNC function reference is terminated.
2)
118 lib.great_table_loc_._.
_
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, ;,
(, ',', ANSIMISS, AS, CROSS, EXCEPT, FULL, GROUP, HAVING,
INNER, INTERSECT, JOIN, LEFT, NATURAL, NOMISS, ORDER, OUTER,
RIGHT, UNION, WHERE.
ERROR 200-322: The symbol is not recognized and will be ignored.
我试过为月份和年份创建一个单独的字段,格式为 YYMMN6。输入 &prompt_date。然后 put(,n.) 使值成为数字 - 仍然没有。
有没有人遇到过类似的问题? 关于如何获得我想要的东西的任何提示?
谢谢!
你有:
%let Date = '&prompt_date.';
%let year = %sysfunc(year(&prompt_date.));
%let month = %sysfunc(month(&prompt_date.));
两个问题。
- 您分配了 &Date 但未使用它。
- 提示日期是 DDMONYYYY(日期 9.)。 SAS 会将其视为一个字符串。您需要引号和
d
才能成为日期。
尝试
%let year = %sysfunc(year("&prompt_date."d));
%let month = %sysfunc(month("&prompt_date."d));