Write to or read from a Microsoft SharePoint site using SAS® software


If your version of SharePoint is SharePoint 365 (also known as SharePoint Online), see the following blog post for code samples and the necessary steps needed to facilitate the communication from SAS to SharePoint: Using SAS with Microsoft 365 (OneDrive, Teams, and SharePoint).

The ability to write to or read from a SharePoint site is controlled by:

If the authentication method that is used by SharePoint is Basic, then access can be made to the site using either of the following:

option set=SHAREPOINT_COMP_MODE 1;
filename sp webdav "http://site.com:81/Shared/sharepoint.txt"
         user="domain\userid" pass="password";
data _null_;
   file sp;
   put 'Hello World';
run;

If the authentication method that is used by SharePoint is NT LAN Manager (NTLM), then access can be made to the site with the third maintenance release of SAS® 9.4M3 (TS1M3) and later running on Windows using the HTTP procedure with the AUTH_NTLM option. Sample code is shown below:

filename input TEMP;
data _null_;
   file input;
   put "this is some sample text";
run;
proc http url="http://site.com:81/Shared/sharepoint.html"
          in=input
          verbose
          webusername="userid"
          webpassword="password"
          method="put"
          auth_ntlm;
run;

If the authentication method used by SharePoint is NTLM, then access can be made to the site with the third maintenance release of SAS 9.4M3 and later running on UNIX where the operating system is Kerberos enabled using the HTTP procedure with the AUTH_NEGOTIATE option. Sample code is shown below:

filename reply TEMP "";
filename headout TEMP "";
proc http url="http://testsite/procHTTP/Shared Documents/test_kerberos"
     in="testing prochttp"
     headerout=headout
     method='put'
     out=reply
     auth_negotiate
     ct='text/html
     charset=utf-8'
     verbose;
run;

There is not currently a method available using SAS code to enable direct communication with the SharePoint site that is configured to use claims-based authentication.