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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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