Desktop productivity for business analysts and programmers

Copy data from SAS windows server to office 365 sharepoint

New Contributor
Posts: 4

Copy data from SAS windows server to office 365 sharepoint

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\*.*"
"\\\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, \\\DavWWWRoot\sites\DISK_VOL2\Doc\RSAN\BAU\file1.csv."

libname mylib "M:\BAU\output_files";
proc export data=mylib.file1
DBMS=CSV replace;

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
    dir user="<my ofc email addy>" pass=<password>;
    data _null_;
       file writeit(shoes);
       put region $25. product $14.;

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.




Super User
Posts: 10,528

Re: Copy data from SAS windows server to office 365 sharepoint

[ Edited ]
Posted in reply to benparado

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;
put _infile_;

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

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation