Dear all,
I have a simple basic code (from Sas Enterprise Guide 7.1) which connects to a server and copies a file from a shared path (between 2 servers) to a local path. part of the code :
%signon;
rsubmit;
/*F is the shared path, D is local*/
data _null_;
x "cd F:\Folder";
x "copy aaa.csv D:\path\folder\aaa.csv";
run;
endrsubmit;
signoff;
When checking the log, it states:
NOTE: Remote submit to SERVER commencing.
Critical error
1 data _null_;
2 x "cd F:\folder"
2 ! ;
3 x "copy aaa.csv D:\path\folder\aaa.csv"
3 ! ;
4 run;
So no copy done.
it is strange that if we try to copy within the same partition it works. this code works:
data _null_;
x "cd D:\folder";
x "copy aaa.csv D:\path\folder\aaa.csv";
run;
There is no case of non - existing files / paths. They do exist.
Any thoughts?
Thanks!
Is the F: drive a network share? If so, you might not have the drive mapping available to you via this SAS/CONNECT session. Instead, you might need to specify the full path, UNC notation, in your copy command.
Example:
copy \\myserver\folder\file.csv D:\dest\folder\.
(I used the dot notation to indicate "copy to the folder using the same file name as the source")
Hi,
I have changed it to:
x "copy \\server\folder\file.csv D:\path\aaa.csv";
The error is gone but still no copy done.
If you want to know what any external command really does, use the filename pipe method:
filename oscmd pipe "copy \\server\folder\file.csv D:\path\aaa.csv 2>&1";
data _null_;
infile oscmd;
input;
put _infile_;
run;
All responses (including those to stderr, that's what the 2>&1 does) will be caught in the SAS log.
This is helpful - the log says "The network name cannot be found."
That folder we try to copy from is shared between a unix server (where we run sas and generate results) to the local path of a windows machine where we have excel installed.
Another approach you can try: The Copy Files task in SAS Enterprise Guide. It's built-in as of v7.13 and available as a download for earlier releases.
Unfortunately we can not use it because we only test the programs using enterprise guide. We need the code to work when sending it to the production enviroment where there is no SAS Enterprise Guide.
Hello,
i have run this command
filename oscmd pipe "net share 2>&1";
and when checking it;
Share name Resource Remark
-------------------------------------------------------------------------------
C$ C:\ Default share
D$ D:\ Default share
IPC$ Remote IPC
ADMIN$ C:\windows Remote Admin
XXXX D:\folderi\SUBFOLDER
The command completed successfully.
I guess it is smth wrong with shared folder F was set ?
If you don't have COPY FILES in your SAS EG, you can try some open source FTP like WinSCP on your windows machine.
@Loko wrote:
Unfortunately we can not use it because we only test the programs using enterprise guide. We need the code to work when sending it to the production enviroment where there is no SAS Enterprise Guide.
Then I'd let the datacenter operators handle the copy from the scheduler. They usually know all their network connections.
I do it like that, quite easily because we have our in/out filenames supplied as environment variables from the scheduler to the SAS jobs.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.