以下代码从 excel 文件中读取手机账单并进行大量清理/报告。
%LET month = March;
..........
PROC IMPORT OUT = PHONE.marchmin
DATAFILE = "D:\Data\cellphone\MarchBill.xls"
DBMS = EXCEL REPLACE;
SHEET = "Calls$";
GETNAMES = YES;
MIXED = YES;
SCANTEXT = YES;
USEDATE = YES;
SCANTIME = YES;
RUN;
为了让我的生活更轻松,我尝试使用宏变量来更新对 March 的所有引用。我最初的想法如下,行不通。
%LET month = March;
.......
PROC IMPORT OUT = PHONE.&monthmin
DATAFILE = "D:\Data\cellphone\&monthBill.xls"
DBMS = EXCEL REPLACE;
SHEET = "Calls$";
GETNAMES = YES;
MIXED = YES;
SCANTEXT = YES;
USEDATE = YES;
SCANTIME = YES;
RUN;
它给出了以下错误:
WARNING: Apparent symbolic reference MONTHMIN not resolved.
1551 PROC IMPORT OUT= PHONE.&monthmin
-
22
ERROR 22-322: Syntax error, expecting one of the following: ;,
(, DATAFILE, DATATABLE, DBMS, FILE, OUT, REPLACE, TABLE.
如何获得对变量月份的引用以正确更新?