DATA Step, Macro, Functions and more

SAS Critical error when copying file

Reply
Super Contributor
Posts: 319

SAS Critical error when copying file

[ Edited ]

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!

Community Manager
Posts: 3,432

Re: SAS Critical error

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")

Super Contributor
Posts: 319

Re: SAS Critical error

Posted in reply to ChrisHemedinger

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.

Super User
Posts: 10,270

Re: SAS Critical error

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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super Contributor
Posts: 319

Re: SAS Critical error

Posted in reply to KurtBremser

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.

Community Manager
Posts: 3,432

Re: SAS Critical error

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.

Super Contributor
Posts: 319

Re: SAS Critical error

Posted in reply to ChrisHemedinger

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.

Super Contributor
Posts: 319

Re: SAS Critical error

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 ?

 

 

Valued Guide
Posts: 596

Re: SAS Critical error

If you don't have COPY FILES in your SAS EG, you can try some open source FTP like WinSCP on your windows machine.

Thanks,
Suryakiran
Super User
Posts: 10,270

Re: SAS Critical error


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.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 9 replies
  • 212 views
  • 2 likes
  • 4 in conversation