Hey All, I've written a macro to do the following; Step 1 is to create a date macro to help import files based on the date on the filename. The second step is to then macro the import process / sorting / merge process based on the date macro. The first step seems to run fine, but when I try and import the datasets within step 2, I get an error related to date not resolved: %macro dates %do i=1 %to &num_months.; data _null_; call symput("date_&i.",strip(put(intnx('months',&startdate.,&i.)-1,date9.))); run; %end; %do i=1 %to &num_months.; %put &&date_&i..; %end; %mend dates; %dates libname temp 'C:\Documents and Settings\My Documents; %macro merge_; %do i=1 %to &num_months.; data debt_&&date_&i..; set temp.bal_&&date_&i..; year_month = intnx('month',&&date_&i..,'beginning'); format year_month DDMMYY10.; run; %end; %mend merge_; %merge_ Log: 19 %macro merge_; 20 %do i=1 %to &num_months.; 21 data debt_&&date_&i..; 22 set temp.bal_&&date_&i..; 23 year_month = intnx('month',&&date_&i..,'beginning'); 24 format year_month DDMMYY10.; 25 run; 26 27 %end; 28 %mend merge_; 29 %merge_ WARNING: Apparent symbolic reference DATE_1 not resolved. NOTE: Line generated by the macro variable "I". 1 debt_&date_1. - 22 ------- 201 WARNING: The Base Product product with which DATASTEP is associated will expire within 30 days. Please contact your SAS installation representative to have it renewed. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, /, ;, _DATA_, _LAST_, _NULL_. ERROR 201-322: The option is not recognized and will be ignored. NOTE: Line generated by the macro variable "I". 1 temp.bal_&date_1. - 22 ------- 201 WARNING: Apparent symbolic reference DATE_1 not resolved. ERROR: File TEMP.bal_.DATA does not exist. NOTE: Line generated by the macro variable "I". 1 &date_1. - 386 76 ------- 201 WARNING: Apparent symbolic reference DATE_1 not resolved. ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, (, ;, END, KEY, KEYS, NOBS, OPEN, POINT, _DATA_, _LAST_, _NULL_. ERROR 201-322: The option is not recognized and will be ignored. ERROR 386-185: Expecting an arithmetic expression. ERROR 76-322: Syntax error, statement will be ignored. NOTE: The SAS System stopped processing this step because of errors. WARNING: The data set WORK.debt_ may be incomplete. When this step was stopped there were 0 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds I'm new to macros, but essentially, the objective is to create a date macro depending on the number of files produced and then macro the import process x number of times without having to write 6 data steps in this case. The above log is only for one file, but there are 6 of the error above (one for each of the six files). Thanks.
... View more