BookmarkSubscribeRSS Feed
benparado
Calcite | Level 5

Hi guys,

 

My team currently have a script to copy output files from SAS windows server (using SAS Enterprise Guide) to a LAN shared network folder. Below is the code that we used to copy all the files from a SAS folder to our office LAN shared folder.

%sysExec xcopy "M:\BAU\output_files\*.*" "\\w01g1bnkfps02x\disk_vol2\RSAN\BAU" /E;

 

However, our office is trying to decommissioned all LAN folders and we are forced to migrate to an Office 365 Sharepoint. I tried replacing the target path to the UNC path of our O365 sharepoint as below. (Note: Our SAS server admin mentioned that the Web Client Services in the SAS server is installed and enabled.)

%sysExec xcopy "M:\BAU\output_files\*.*"
"\\myofc.sharepoint.com@SSL\DavWWWRoot\sites\DISK_VOL2\Doc\RSAN\BAU" /E;

After executing there were no files copied in the sharepoint folder. I tried a simple export to check if I can copy 1 file in the Sharepoint folder. However I got an error "ERROR: Physical file does not exist, \\myofc.sharepoint.com@SSL\DavWWWRoot\sites\DISK_VOL2\Doc\RSAN\BAU\file1.csv."

libname mylib "M:\BAU\output_files";
proc export data=mylib.file1
outfile="\\myofc.sharepoint.com@SSL\DavWWWRoot\sites\DISK_VOL2\Doc\RSAN\BAU\file1.csv"
DBMS=CSV replace;
run;

I also tried using the filename webdav code I found in a SAS documentation site, but it returned me an error "ERROR: No logical assign for filename WRITEIT. ERROR: Error in the FILENAME statement."

options set=sharepoint_comp_mode 1;
filename writeit webdav
   "https://myofc.sharepoint.com/sites/DISK_VOL2/Doc/RSAN/BAU/"
    dir user="<my ofc email addy>" pass=<password>;
    data _null_;
       file writeit(shoes);
       set sashelp.shoes;
       put region $25. product $14.;
    run;

Is there other way we can transfer files from a SAS window-based server to an Office 365 sharepoint? Our team's issue is the output files we generate every month is quite a lot and if we copy the files manually from SAS server to a local computer and from local computer to the Sharepoint folder, it will take a lot of time and effort to do it. 

 

Thanks in advance for any help, suggestion and advice.

 

Regards,

Ben

1 REPLY 1
Kurt_Bremser
Super User

Before using a system command from SAS, make sure that it performs correctly by running it from the commandline. Once that is made sure of, run it from SAS.

If you can't get a commandline interface on the server, use this in SAS to get all system output into the SAS log:

filename oscmd pipe "command 2>&1";

data _null_;
infile oscmd;
input;
put _infile_;
run;

This can give you a clue what's going wrong.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1673 views
  • 0 likes
  • 2 in conversation