以下代码从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.
如何正确更新对变量月份的引用?
答案 0 :(得分:8)
在一个月后放一段时间。所以SAS知道宏变量的结尾在哪里。 e.g。
PROC IMPORT OUT = PHONE.&month.min
DATAFILE = "D:\Data\cellphone\&month.Bill.xls"