BookmarkSubscribeRSS Feed
Loko
Barite | Level 11

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!

9 REPLIES 9
ChrisHemedinger
Community Manager

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

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Loko
Barite | Level 11

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.

Kurt_Bremser
Super User

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.

Loko
Barite | Level 11

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.

ChrisHemedinger
Community Manager

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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
Loko
Barite | Level 11

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.

Loko
Barite | Level 11

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 ?

 

 

SuryaKiran
Meteorite | Level 14

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
Kurt_Bremser
Super User

@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-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
  • 9 replies
  • 1799 views
  • 2 likes
  • 4 in conversation