DATA Step, Macro, Functions and more

syntax error for infile input?

Accepted Solution Solved
Reply
Super Contributor
Posts: 319
Accepted Solution

syntax error for infile input?

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.

 


Accepted Solutions
Solution
3 weeks ago
Super User
Posts: 7,845

Re: syntax error for infile input?

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Solution
3 weeks ago
Super User
Posts: 7,845

Re: syntax error for infile input?

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

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

Discussion stats
  • 1 reply
  • 94 views
  • 1 like
  • 2 in conversation