I am trying to pass numeric variables into this macro. I am able to pass it through the KEEP and SET statements, but when it gets to the RENAME statement I get these errors:
ERROR: Variable '2013'n is not on file WORK.'2013'n.
ERROR: Invalid DROP, KEEP, or RENAME option on file WORK.'2013'n.
%macro step2(year,cwyear);
TITLE; FOOTNOTE;
DATA WORK._EG_CFMT;
LENGTH label $ 9;
SET WORK."&year."n (KEEP="&year."n "&cwyear."n RENAME=("&year."n =start "&year."n =label)) END=__last;
RETAIN fmtname "cw&year."n type "C";
end=start;
RUN;
%mend step2;
When I change the double quotes around &year. to single quotes, like this:
SET WORK.'&year.'n (KEEP="&year."n "&cwyear."n RENAME=("&year."n =start "&year."n =label))
I get this error:
ERROR: File WORK.'&YEAR.'n.DATA does not exist.
When I change back to all double quotes and remove the n's, I get the following error:
ERROR 22-322: Syntax error, expecting one of the following: a name, a quoted string, ;, CUROBS, END, INDSNAME, KEY, KEYRESET, KEYS, NOBS, OPEN, POINT, DATA, LAST, NULL.
How do I make this work?
Thanks for the help!
nwhen you change to double quotes? - Joe