Help using Base SAS procedures

Macro reference couldn't be resolved?

Accepted Solution Solved
Reply
Super Contributor
Posts: 398
Accepted Solution

Macro reference couldn't be resolved?

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.


Accepted Solutions
Solution
‎05-17-2018 11:32 AM
Respected Advisor
Posts: 3,001

Re: Macro reference couldn't be resolved?

[ Edited ]

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. 

--
Paige Miller

View solution in original post


All Replies
Solution
‎05-17-2018 11:32 AM
Respected Advisor
Posts: 3,001

Re: Macro reference couldn't be resolved?

[ Edited ]

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. 

--
Paige Miller
Super Contributor
Posts: 398

Re: Macro reference couldn't be resolved?

Posted in reply to PaigeMiller

Thanks much!  I got it worked!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 154 views
  • 0 likes
  • 2 in conversation