开发者

SAS Macro-variable reference concatenation

开发者 https://www.devze.com 2023-02-20 15:20 出处:网络
The following code reads in a cellphone bill from an excel file and do a lot of cleaning / reports. %LET month = March;

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:\Da开发者_JAVA百科ta\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?


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"  
0

精彩评论

暂无评论...
验证码 换一张
取 消