BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
comeon2012
Fluorite | Level 6

Hi,

There are tens of csv files in folder D:\users\...\desktop\list. I need to import them into SAS.

For illustration purpose, I only take 2 files as the example.

%let country1=abudhabi;

%let country2=argentina;

%macro import;

%do i =1 % to 2;

proc import out = &&country&i

                 datafile="D:\users\...\desktop\list\&&country&i.csv"

                 dbms=csv replace;

run;

%end;;

%mend import;

%import;

But the codes did not work and the error messages are as below:

*WARNING: Apparent symbolic reference D not resolved;

*WARNING: Apparent symbolic reference D not resolved;

*WARNING: Apparent symbolic reference COUNTRY1CSV not resolved;

*ERROR: Physical file does not exist,D:\Users\...\Desktop\list\&&country&i.csv;

*ERROR: Import unsuccessful. See SAS Log for details.;


Can anyone advise me what the problem is and how to resovle it? Thanks.

1 ACCEPTED SOLUTION

Accepted Solutions
Alpay
Fluorite | Level 6

You are right. I did not test it before I submitted above code.

First period acts as a delimiter for &i in the first pass.

Second period acts as a delimiter for &Country1 in the second pass.

&&Country&i.csv -> Country1csv

&&Country&i..csv -> abudahbicsv

&&Country&i...csv -> abudhabi.csv

View solution in original post

3 REPLIES 3
Alpay
Fluorite | Level 6

&&country&i.csv  will resolve to Country1csv for i=1. && will resolve to & and &i will resolve to 1 in the first pass.

Macro facility will try to resolve &Country1csv macro variable reference which fails.

The single period following macro variable reference will act as a delimiter and won't be part of the resulting text.

You will need to insert another '.' (period) after &&country&i to delimit the value of macro variable from the the file extension.

Replace '&&country&i.csv' to '&&country&i..csv'

I am not sure about the warning 'WARNING: Apparent symbolic reference D not resolved;' I could not see where macro variable D is referenced in the code.

comeon2012
Fluorite | Level 6

It still did not work when I add another period.

But after I accidentally added another two period, i.e,  '&&country&i...csv', it worked although  'WARNING: Apparent symbolic reference D not resolved' still appeared. Anyways, the csv file were imported to SAS. Thank you Alpay.

Alpay
Fluorite | Level 6

You are right. I did not test it before I submitted above code.

First period acts as a delimiter for &i in the first pass.

Second period acts as a delimiter for &Country1 in the second pass.

&&Country&i.csv -> Country1csv

&&Country&i..csv -> abudahbicsv

&&Country&i...csv -> abudhabi.csv

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 2519 views
  • 4 likes
  • 2 in conversation