Hello:
I wrote the macro codes below. I found something is wrong when I use "importpath" macro. Could someone help? Thanks.
%let sheetname=crowding2009;
%let importpath=\\abc.org\project\ACS\CA\2009
filename in "&importpath..\&sheetname..csv";
data &sheetname;
infile in MISSOVER DSD firstobs=3;
input
GEO_id $
GEO_id2 $
GEO_display_label $
HD01_VD01 $
HD02_VD01 $;
run;
The log shows below.
81 options mprint symbolgen mlogic;
82 %let sheetname=crowding2009;
83 %let importpath=\\abc.org\project\ACS\CA\2009
84 filename in "&importpath..\&sheetname..csv";
SYMBOLGEN: Macro variable IMPORTPATH resolves to \\abc.org\project\ACS\CA\2009 filename in "\crowding2009.csv"
SYMBOLGEN: Macro variable SHEETNAME resolves to crowding2009
85
SYMBOLGEN: Macro variable SHEETNAME resolves to crowding2009
ERROR: No logical assign for filename IN.
However the codes works below. So I am confused that what went wrong for the one above.
options mprint symbolgen mlogic;
%let sheetname=crowding2009;
filename in "\\abc.org\project\ACS\CA\2009\&sheetname..csv";
In your original text, your code is innacurate:
83 %let importpath=\\abc.org\project\ACS\CA\2009
84 filename in "&importpath..\&sheetname..csv";
Note that there is a missing semicolon after 2009
Your FILENAME statement has two dots after &IMPORTPATH, but there should only be one.
Most of the time, the reason to use two dots is because the second dot should become text, and should be a character within the program.
When I put one dot, it didn't work either. Then I put two dots.
184 filename in "&importpath.\&sheetname..csv";
WARNING: Apparent symbolic reference IMPORTPATH not resolved.
In your original text, your code is innacurate:
83 %let importpath=\\abc.org\project\ACS\CA\2009
84 filename in "&importpath..\&sheetname..csv";
Note that there is a missing semicolon after 2009
You are right, thanks.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.