SAS 宏变量引用串联

发布于 2024-10-27 11:43:38 字数 1089 浏览 0 评论 0原文

以下代码从 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

挽袖吟 2024-11-03 11:43:38

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

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

Put a period after &month. so SAS knows where the end of the macro variable is.
e.g.

PROC IMPORT OUT = PHONE.&month.min
   DATAFILE = "D:\Data\cellphone\&month.Bill.xls"  
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文