BookmarkSubscribeRSS Feed
siddhu1
Obsidian | Level 7

Hi,

I need some help, While executing the below code in the SAS Studio environment,
%let outpath=G:\Data\CXV\PGMSs\Test;
%put &outpath is ;

data shorts1;
set sashelp.cars;
run;
proc export data=shorts1
outfile="&outpath/shorts.csv"
dbms=csv replace;
run;

I was getting the below error:

ERROR: Physical file does not exist, D:\SAS\Config\Lev1\SASApp1-u8/&outpath/shorts.csv.
The files has been created in the config folder.
So can you help us in knowing the reason how it has been created.

Thanks & Regards,
Siddhartha

4 REPLIES 4
JosvanderVelden
SAS Super FREQ
Maybe it works if you use outfile="&outpath./shorts.csv"?

It seems the &outpath is not substituted. Are there other error messages or warnings? Do you have comments that prevent execution of the code in question?
Kurt_Bremser
Super User

Post the complete (all statements and messages) log from this code:

%let outpath=G:\Data\CXV\PGMSs\Test;
%put outpath is &outpath.;

data shorts1;
set sashelp.cars;
run;
proc export data=shorts1
outfile="&outpath./shorts.csv"
dbms=csv replace;
run;

by copy/pasting it into a window opened with the </> button.

BIG hint: the last message is usually the least important, but fixing the first issue can fix all others.

Tom
Super User Tom
Super User

So one of two things appears to be happening.

Either you actually ran the code using single quotes instead of the double quotes .

outfile='&outpath/shorts.csv'

The macro processor ignores string literals bounded by single quotes.

 

Or the macro variable OUTPATH was not defined.  In that case you should have received a WARNING message:

7729  %put "&outpath/myfile.csv";
WARNING: Apparent symbolic reference OUTPATH not resolved.
"&outpath/myfile.csv"

Either way once the operating system sees that SAS is using a RELATIVE pathname so it tries the create a file under the current working directory, which appears to be on that disk/sharename that is mounted as the  D drive.

 

Sajid01
Meteorite | Level 14

Please check if the path specified in the macro assignment actually exists.
Please note the path should exist on the machine where the code is being executed.
If the code is being executed on the server, then the: G:\" refers to the G driver on the server.
The code is syntactically correct and will go wrong if the path is incorrect. I have tested your code and it works.
Please post the output of the following

%let outpath=G:\Data\CXV\PGMSs\Test;
%put &=outpath  ;

suga badge.PNGThe SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment. 

Join SUGA 

Get Started with SAS Information Catalog in SAS Viya

SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 627 views
  • 0 likes
  • 5 in conversation