SAS 宏变量引用串联
以下代码从 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.
如何获取对变量月份的引用以正确更新?
The following code reads in a cellphone bill from an excel file and do a lot of cleaning / reports.
%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;
To make my life easier, I'm trying to use a macro variable to update all of the references to March. My initial idea below, doesn't work.
%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;
It gives the following error:
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.
How do I get that reference to the variable month to update correctly?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 &month 后面加上句号。所以SAS知道宏变量的结尾在哪里。
例如
Put a period after &month. so SAS knows where the end of the macro variable is.
e.g.