Hi all:
I have a macro code below. I found log view showed one error while I ran the codes. Please let me know how to fix it. Thanks.
options mprint symbolgen mlogic;
%let Year=2014;
%let YY=14;
%let Table1=B02;
%let Table2=B19;
.
.
.
.
%let Table12=S408;
%let importfolder=pathway\All_US_&year.;
%macro import;
%do i = 1 %to 12;
PROC IMPORT OUT=ACS_&YY._5YR_&&TABLE&i
DATAFILE= "&importfolder.\ACS_&YY._5YR_&&TABLE&i._with_ann.csv"
DBMS=CSV REPLACE;
GETNAMES=YES;
DATAROW=2;
GUESSINGROWS=MAX;
RUN;
%end;
%mend;
%import;
The error message is shown below.
MLOGIC(IMPORT): Beginning execution.
MLOGIC(IMPORT): %DO loop beginning; index variable I; start value is 1; stop value is 2; by
value is 1.
SYMBOLGEN: Macro variable YY resolves to 14
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
SYMBOLGEN: Macro variable TABLE1 resolves to B02001
SYMBOLGEN: Macro variable IMPORTFOLDER resolves to
Pathway\All_US_2014
SYMBOLGEN: Macro variable YY resolves to 14
SYMBOLGEN: && resolves to &.
SYMBOLGEN: Macro variable I resolves to 1
WARNING: Apparent symbolic reference TABLE1_WITH_ANN not resolved.
MPRINT(IMPORT): PROC IMPORT OUT=ACS_14_5YR_B02001 DATAFILE=
"Pathway\All_US_2014\ACS_14_5YR_&TABLE1_with_ann.csv" DBMS=CSV REPLACE;
MPRINT(IMPORT): ADLM;
MPRINT(IMPORT): GETNAMES=YES;
MPRINT(IMPORT): DATAROW=2;
MPRINT(IMPORT): GUESSINGROWS=MAX;
MPRINT(IMPORT): RUN;
ERROR: Physical file does not exist, pathway\All_US_2014\ACS_14_5YR_&TABLE1_with_ann.csv.
ERROR: Import unsuccessful. See SAS Log for details.
This is the fix
DATAFILE= "&importfolder.\ACS_&YY._5YR_&&TABLE&i.._with_ann.csv"
You need two dots after &&TABLE&I in order to indicate the end of the macro variable name and the beginning of extra non-macro text.
This is the fix
DATAFILE= "&importfolder.\ACS_&YY._5YR_&&TABLE&i.._with_ann.csv"
You need two dots after &&TABLE&I in order to indicate the end of the macro variable name and the beginning of extra non-macro text.
Thanks much! I got it worked!
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.