Hello:
I have infile codes below and I got error message from log. Please help. Thanks.
options mprint symbolgen mlogic;
libname MedSCN "\\abc.org\PROJECTS\MedScreen\SAS";
%let Sheetname=ScreenClass;
Filename "\\abc.org\PROJECTS\MedScreen\SAS\&sheetname..csv";
data medscn.&sheetname;
infile filename MISSOVER DSD firstobs=2;
input
Group $
Analysis Group $200.
Class Label $300.
run;
230 %let Sheetname=ScreenClass;
SYMBOLGEN: Macro variable SHEETNAME resolves to ScreenClass
231 Filename
231! "\\abc.org\PROJECTS\MedScreen\SAS\&sheetname..csv\&sheetna
231! me..csv";
ERROR: Invalid logical name.
ERROR: Error in the FILENAME statement.
232
SYMBOLGEN: Macro variable SHEETNAME resolves to ScreenClass
233 data medscn.&sheetname;
234 infile filename MISSOVER DSD firstobs=2;
235 input
236 Group $
237 Analysis Group $200.
239 Class Label $300.
264 run;
ERROR: No logical assign for filename FILENAME.
This is invalid:
Filename "\\abc.org\PROJECTS\MedScreen\SAS\&sheetname..csv";
You have to supply a logical name for the file reference:
filename in "\\abc.org\PROJECTS\MedScreen\SAS\&sheetname..csv";
And then you use that in the import code:
data medscn.&sheetname;
infile ine MISSOVER DSD firstobs=2;
input
Group $
Analysis Group $200.
Class Label $300.
;
run;
PS your import code misses a semicolon and would therefore input a variable called run.
This is invalid:
Filename "\\abc.org\PROJECTS\MedScreen\SAS\&sheetname..csv";
You have to supply a logical name for the file reference:
filename in "\\abc.org\PROJECTS\MedScreen\SAS\&sheetname..csv";
And then you use that in the import code:
data medscn.&sheetname;
infile ine MISSOVER DSD firstobs=2;
input
Group $
Analysis Group $200.
Class Label $300.
;
run;
PS your import code misses a semicolon and would therefore input a variable called run.
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.