Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAS Macro-variable reference concatenation

Tags:

sas

sas-macro

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?

like image 603
DataParadigms Avatar asked Feb 24 '23 16:02

DataParadigms


1 Answers

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"  
like image 167
cmjohns Avatar answered Apr 29 '23 18:04

cmjohns