Desktop productivity for business analysts and programmers

Exporting a file from SAS EG to Sharepoint Location

Reply
Occasional Contributor
Posts: 12

Exporting a file from SAS EG to Sharepoint Location

I tried to run below code in SAS EG

 

options notes source;

filename reply "http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml";

filename headout TEMP "";

proc http url="http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml"

      in="testing prochttp"

      headerout=headout

      method='put'

      out=reply

      auth_negotiate

      ct='text/html

      charset=utf-8'

      verbose;

run;

 

Actuall path on the server is http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml

 

But when I tried to execute the above code it is resolving as /sas/config9_4/compute/Lev2/SASApp/http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml. with below error

 

 

ERROR: Physical file does not exist,

       /sas/config9_4/compute/Lev2/SASApp/http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml.

 

when resolving “/sas/config9_4/compute/Lev2/SASApp” is getting added to actuall path http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml

 

Can you please help me out with this !

Esteemed Advisor
Posts: 6,646

Re: Exporting a file from SAS EG to Sharepoint Location

out= is meant to be a local file where the response from the server (basically the confirmation of your put request) is saved. Don't use a URL for it.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 12

Re: Exporting a file from SAS EG to Sharepoint Location

I would like to "put" the output file directly on the sharepoint location dynamically ,would it be possible ?

 

"http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports/logging.xml";

 

Esteemed Advisor
Posts: 6,646

Re: Exporting a file from SAS EG to Sharepoint Location

The "out" will only contain the server's response, NOT any data that you provided. If you want to put that onto the server, you'd need another proc http after saving it locally.

 

Look at the example in http://support.sas.com/documentation/cdl/en/proc/70377/HTML/default/viewer.htm#n0vfw4ml5fwn4un1ru90x...

url= where your data is put.

in= shall be a (local) file reference for the data you want to send to the URL.

out= shall be a file reference where the server response goes. (you might want to look at it to confirm that the post or put worked)

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 12

Re: Exporting a file from SAS EG to Sharepoint Location

in that case all the reports  placed in "resp" needs to be mapped to the sharepoint location  given in the URL (please see my code below)"http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports "

 

does it happen automatically or do we need to map the output location to the URL behind the scenes via sas admin.

 

 

options notes source;

filename resp '/WBIO_Shared/WLS_REPORTS/test1.xlsx';

filename headout TEMP;

filename input TEMP;

data _null_;

file input;

put "this is some sample text";

run;

proc http

url="http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports"

in=input

out=resp

headerout=headout;

/* webusername="****"*/

/* webpassword="****"*/

/* auth_negotiate;*/

run;

Esteemed Advisor
Posts: 6,646

Re: Exporting a file from SAS EG to Sharepoint Location

I hate to repeat myself, but the out= destination is used to store the server's response. This response follows the HTTP protocol and is pure text, storing it in an Excel file does not, I repeat not make sense.

The data you want to "upload" (using POST or PUT) comes from file reference in=

 

If you want all reports named in your xlsx file to upload, convert it to a SAS dataset and then use call execute from that dataset to create the upload codes dynamically.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 12

Re: Exporting a file from SAS EG to Sharepoint Location

Thank you , I have executed it , it says "401 unauthorized" as server response, i have individual access to the sharepoint URL: but when im executing from SAS EG i think i donot have access , is it some thing sas admin needs to set it up on the backend ?

 

options notes source;

filename resp '/WBIO_Shared/WLS_REPORTS/test1.txt';

filename headout TEMP;

filename input '/WBIO_Shared/WLS_REPORTS/test1.xlsx';

data _null_;

file input;

put "this is some sample text";

run;

proc http

url="http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports"

in=input

out=resp

headerout=headout

webusername="***"

webpassword="***"

auth_negotiate;

run;

Esteemed Advisor
Posts: 6,646

Re: Exporting a file from SAS EG to Sharepoint Location

Add

method="PUT"

to your proc http statement. The default method when in= is specified is POST, which expects a script on the serverside to handle the data.

So I guess you should do a PUT to copy your data to sharepoint.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 12

Re: Exporting a file from SAS EG to Sharepoint Location

Still im getting same reponse from server:

 

HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
Server: Microsoft-IIS/8.0
SPRequestGuid: 0196e09d-8842-002c-da17-bfcfdca31a32
request-id: 0196e09d-8842-002c-da17-bfcfdca31a32
X-FRAME-OPTIONS: SAMEORIGIN
SPRequestDuration: 3
SPIisLatency: 0
WWW-Authenticate: NTLM
X-Powered-By: ASP.NET
MicrosoftSharePointTeamServices: 15.0.0.4535
X-Content-Type-Options: nosniff
X-MS-InvokeApp: 1; RequireReadOnly
Date: Wed, 22 Mar 2017 18:06:54 GMT
Content-Length: 16

 

Esteemed Advisor
Posts: 6,646

Re: Exporting a file from SAS EG to Sharepoint Location

I did some searching around (GIYF) and found this:

https://communities.sas.com/t5/Base-SAS-Programming/How-to-read-data-from-the-SharePoint/td-p/30734

There, sharepoint is used just like a simple network mount / file path.

Have you already tried simply writing a file to sharepoint, like

filename out "\\sharepoint\path\filename.dat";

data _null_;
file out;
put "this is just a test";
run;

?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 12

Re: Exporting a file from SAS EG to Sharepoint Location

yes i have tried noluck , but my url looks something like this starting with http

 

http://sites.suntrust.com/teams/WholesaleInfoDelivery/Portal%20Reports

 

Esteemed Advisor
Posts: 6,646

Re: Exporting a file from SAS EG to Sharepoint Location

Then I can only recommend to contact SAS technical support.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 11 replies
  • 241 views
  • 0 likes
  • 2 in conversation