gpt4 book ai didi

SAS 宏变量引用连接

转载 作者:行者123 更新时间:2023-12-04 19:17:48 24 4
gpt4 key购买 nike

以下代码从 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.

如何获得对变量月份的引用以正确更新?

最佳答案

在 &month 之后加上句点。所以 SAS 知道宏变量的结尾在哪里。
例如

PROC IMPORT OUT = PHONE.&month.min
DATAFILE = "D:\Data\cellphone\&month.Bill.xls"

关于SAS 宏变量引用连接,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5488301/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com