BookmarkSubscribeRSS Feed
LeeJenson
Calcite | Level 5
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
6 REPLIES 6
Tim_SAS
Barite | Level 11
Macro variables aren't expanded when they're within apostrophes. Use quotes instead:

[pre]
proc import datafile = "c:\&expfile." out=work.fields_tmp1;
[/pre]
LeeJenson
Calcite | Level 5
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
LinusH
Tourmaline | Level 20
options symbolgen; would help you.
/Linus
Data never sleeps
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
Suggest you use the options statement below:

OPTIONS SOURCE SOURCE2 MACROGEN SYMBOLGEN MPRINT;

...and sometimes...

OPTIONS MLOGIC;

Scott Barry
SBBWorks, Inc.
LeeJenson
Calcite | Level 5
Hi

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

Thanks again
:-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-):-)
Lee
How to Concatenate Values

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 6 replies
  • 4853 views
  • 0 likes
  • 4 in conversation