DATA Step, Macro, Functions and more

ERROR: Unable to import, file c:\&expfile.XLS does not exist

Reply
Contributor
Posts: 33

ERROR: Unable to import, file c:\&expfile.XLS does not exist

Hi,

I am trying to collect a file name from a field but the variable does
not seem to get translated. My source dataset only has one record in
so should pick it up ok.


proc sql;
select name into :expfile
from exportfilec;
quit;


proc import datafile = 'c:\&expfile.' out=work.fields_tmp1;
run;


99 proc import datafile = 'c:\&expfile.' out=work.fields_tmp1;
100 run;


ERROR: Unable to import, file c:\&expfile.XLS does not exist
Super Contributor
Posts: 394

Re: ERROR: Unable to import, file c:\&expfile.XLS does not exist

Posted in reply to LeeJenson
Macro variables aren't expanded when they're within apostrophes. Use quotes instead:

[pre]
proc import datafile = "c:\&expfile." out=work.fields_tmp1;
[/pre]
Contributor
Posts: 33

Re: ERROR: Unable to import, file c:\&expfile.XLS does not exist

Thank you :-)
Contributor
Posts: 33

Re: ERROR: Unable to import, file c:\&expfile.XLS does not exist

Posted in reply to LeeJenson
Tim,

If I replace the single quote with double quotes I get this error...

235 proc import datafile = "C:\&expfile." out=work.fields_tmp1;
ERROR: Unable to determine datasource type. Please use the DBMS= option.

What is the best method to output the content of a variable to the log just to see what's in it?

Lee
Super User
Posts: 5,428

Re: ERROR: Unable to import, file c:\&expfile.XLS does not exist

Posted in reply to LeeJenson
options symbolgen; would help you.
/Linus
Data never sleeps
Super Contributor
Super Contributor
Posts: 3,174

Re: ERROR: Unable to import, file c:\&expfile.XLS does not exist

Suggest you use the options statement below:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT;

...and sometimes...

OPTIONS MLOGIC;

Scott Barry
SBBWorks, Inc.
Contributor
Posts: 33

Re: ERROR: Unable to import, file c:\&expfile.XLS does not exist

Hi

These options allowed me to troubleshoot the problem and it was because I was not specifying DBMS=CSV.

Thanks again
:-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-)
Lee
Ask a Question
Discussion stats
  • 6 replies
  • 1717 views
  • 0 likes
  • 4 in conversation