I'm searching to export a file to Sharepoint with SAS, this is what I tried :
filename input "C:\Users\xxx.xxx\xxx\xxx\xxx\xxx\a.txt";proc http url="https://xxx.sharepoint.com/xxx/xxx/xxx/xxxx/Espace%20Public.aspx"
in=input
webusername="xxx.xxx@xxx.com" webpassword="XXX" method="put"; run;
So this code compilate with no errors but doesn't export the file, any help is welcome. Thanks
If the authentication method used by the SharePoint is NTLM you would need an additional line in your PROC step.
Depending on wherther you are running on Windows or SAS, you would need to add one of these two lines:
Running on Windows (add this logic to your PROC step):
auth_ntlm;
Running on UNIX (Add this logic to your PROC step:
auth_negotiate;
See documentation - http://support.sas.com/kb/42/054.html
Thanks for your answer, when I test that I have an error :
30 auth_ntlm;
_________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, CT, HEADERIN, HEADEROUT, HTTP_TOKENAUTH, IN, JAVA_HTTP, METHOD, OUT,
PROXYHOST, PROXYPASSWORD, PROXYPORT, PROXYUSERNAME, URL, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
@Red1 wrote:
Thanks for your answer, when I test that I have an error :
30 auth_ntlm; _________ 22 202 ERROR 22-322: Syntax error, expecting one of the following: ;, CT, HEADERIN, HEADEROUT, HTTP_TOKENAUTH, IN, JAVA_HTTP, METHOD, OUT, PROXYHOST, PROXYPASSWORD, PROXYPORT, PROXYUSERNAME, URL, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME. ERROR 202-322: The option or parameter is not recognized and will be ignored.
Please show entire proc or statement. Many syntax errors involve something before the indicated error.
1 Le Système SAS 17:01 Wednesday, May 22, 2019
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Programme (2)';
4 %LET _CLIENTPROJECTPATH='C:\XX\XXX\Projet.egp';
5 %LET _CLIENTPROJECTNAME='Projet.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///D:/SAS/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 filename input "C:\Users\XXXXX\a.txt";
24
25 proc http
25 ! url="https://XXX.sharepoint.com/Documents%20partages/Forms/AllItems.aspx?viewpath=%2FDocuments%20partages%2FForms%2FAl
25 ! lItems.aspx"
26 in=input
27 webusername="XX.XX@XX.com"
28 webpassword=XXXXXXXXXXXX
29 method="put"
30 auth_ntlm;
_________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, CT, HEADERIN, HEADEROUT, HTTP_TOKENAUTH, IN, JAVA_HTTP, METHOD, OUT,
PROXYHOST, PROXYPASSWORD, PROXYPORT, PROXYUSERNAME, URL, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
31 run;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.00 secondes
cpu time 0.01 secondes
32
33 GOPTIONS NOACCESSIBLE;
34 %LET _CLIENTTASKLABEL=;
35 %LET _CLIENTPROJECTPATH=;
36 %LET _CLIENTPROJECTNAME=;
37 %LET _SASPROGRAMFILE=;
38
39 ;*';*";*/;quit;run;
40 ODS _ALL_ CLOSE;
41
42
2 Le Système SAS 17:01 Wednesday, May 22, 2019
43 QUIT; RUN;
44
Here it is
did you add the 'auth_ntlm;' logic after the 'run' statement?
Its hard to tell from the details you provided. If that is the case, to test out this additional logic, you will need to include it within the PROC HTTP data step (after 'PROC HTTP' and before the 'run' statement for the procedure.
Sorry, I put it before run; like that :
proc http url="https://xx.sharepoint.com/Documents%20partages/Forms/AllItems.aspx?viewpath=%2FDocuments%20partages%2FForms%2FAllItems.aspx"
in=input
webusername="xx@xx.com"
webpassword="xx"
method="put"
auth_ntlm;
run;
you can try running this logic to create the prochttp_check_return macro.
%macro prochttp_check_return(code);
%if %symexist(SYS_PROCHTTP_STATUS_CODE) ne 1 %then %do;
%put ERROR: Expected &code., but a response was not received from
the HTTP Procedure;
%abort;
%end;
%else %do;
%if &SYS_PROCHTTP_STATUS_CODE. ne &code. %then %do;
%put ERROR: Expected &code., but received &SYS_PROCHTTP_STATUS_CODE.
&SYS_PROCHTTP_STATUS_PHRASE.;
%abort;%end;
%end;
%mend;
Then after your proc http logic, run this piece:
%prochttp_check_return(200);
Then you check your log to see what error descriptions may be listed to explain what the issue is, no guarantees.
Here is the result :
1 Le Système SAS 17:01 Wednesday, May 22, 2019
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Programme (2)';
4 %LET _CLIENTPROJECTPATH='C:\Users\xxx.XXX\Desktop\Stage\Mantis\testExport\Projet.egp';
5 %LET _CLIENTPROJECTNAME='Projet.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///D:/SAS/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
23 filename input "C:\Users\xxx.XXX\Desktop\Stage\Mantis\testExport\a.txt";
24
25 proc http
25 ! url="https://xxx.sharepoint.com/Documents%20partages/Forms/AllItems.aspx?viewpath=%2FDocuments%20partages%2FForms%2FAl
25 ! lItems.aspx"
26 in=input
27 webusername="xxx.xxx@xxx.com"
28 webpassword=XXXXXXXXXXXX
29 method="put"
30 auth_ntlm;
_________
22
202
ERROR 22-322: Syntax error, expecting one of the following: ;, CT, HEADERIN, HEADEROUT, HTTP_TOKENAUTH, IN, JAVA_HTTP, METHOD, OUT,
PROXYHOST, PROXYPASSWORD, PROXYPORT, PROXYUSERNAME, URL, VERBOSE, WEBAUTHDOMAIN, WEBPASSWORD, WEBUSERNAME.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
31 run;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE HTTP used (Total process time):
real time 0.00 secondes
cpu time 0.00 secondes
32
33 %macro prochttp_check_return(code);
34 %if %symexist(SYS_PROCHTTP_STATUS_CODE) ne 1 %then %do;
35 %put ERROR: Expected &code., but a response was not received from
36 the HTTP Procedure;
37 %abort;
38 %end;
39 %else %do;
40 %if &SYS_PROCHTTP_STATUS_CODE. ne &code. %then %do;
41 %put ERROR: Expected &code., but received &SYS_PROCHTTP_STATUS_CODE.
42 &SYS_PROCHTTP_STATUS_PHRASE.;
2 Le Système SAS 17:01 Wednesday, May 22, 2019
43 %abort;%end;
44 %end;
45 %mend;
46
47
48 %prochttp_check_return(200);
ERROR: Expected 200, but a response was not received from the HTTP Procedure
ERROR: Execution terminated by an %ABORT statement.
49
50 GOPTIONS NOACCESSIBLE;
51 %LET _CLIENTTASKLABEL=;
52 %LET _CLIENTPROJECTPATH=;
53 %LET _CLIENTPROJECTNAME=;
54 %LET _SASPROGRAMFILE=;
55
56 ;*';*";*/;quit;run;
57 ODS _ALL_ CLOSE;
58
59
60 QUIT; RUN;
61
Hi @Red1 running on Windows, you should be able to just copy the file with the host command:
X copy "c:\users\xxx\xx\xx.txt" "\\xxx.sharepoint.com\site\doclib";
If host commands are disabled at your site, or, better yet, when you create the text file just point the output fileref to "\\xxx.sharepoint.com\site\doclib\xx.txt";
Hope this helps.
Thanks a lot for your answer, it works when I try it in the terminal, but when I try in SAS, it tells me that there is no file in this directory.... I tried that :
data _null_;
X 'copy C:\Users\XX.XX\Desktop\Stage\Mantis\testExport\qsf.txt \\XX.sharepoint.com\Documents%20partages\qsf.txt';
run;
I also tried like that :
X copy 'C:\Users\XX.XX\Desktop\Stage\Mantis\testExport\qsf.txt \\XX.sharepoint.com\Documents%20partages\qsf.txt';
or like that
X copy 'C:\Users\xx.xx\Desktop\Stage\Mantis\testExport\qsf.txt' '\\XXX.sharepoint.com\Documents%20partages\qsf.txt';
Same error :
1 Le Système SAS 17:01 Wednesday, May 22, 2019
1 ;*';*";*/;quit;run;
2 OPTIONS PAGENO=MIN;
3 %LET _CLIENTTASKLABEL='Programme (2)';
4 %LET _CLIENTPROJECTPATH='C:\Users\XXX.XXX\Desktop\Stage\Mantis\testExport\Projet.egp';
5 %LET _CLIENTPROJECTNAME='Projet.egp';
6 %LET _SASPROGRAMFILE=;
7
8 ODS _ALL_ CLOSE;
9 OPTIONS DEV=ACTIVEX;
10 GOPTIONS XPIXELS=0 YPIXELS=0;
11 FILENAME EGSR TEMP;
12 ODS tagsets.sasreport13(ID=EGSR) FILE=EGSR
13 STYLE=HtmlBlue
14 STYLESHEET=(URL="file:///D:/SAS/SASEnterpriseGuide/7.1/Styles/HtmlBlue.css")
15 NOGTITLE
16 NOGFOOTNOTE
17 GPATH=&sasworklocation
18 ENCODING=UTF8
19 options(rolap="on")
20 ;
NOTE: Writing TAGSETS.SASREPORT13(EGSR) Body file: EGSR
21
22 GOPTIONS ACCESSIBLE;
Le fichier spécifié est introuvable.
23 data _null_;
24 X 'copy C:\Users\XXX.XXX\Desktop\Stage\Mantis\testExport\qsf.txt
24 ! \\XXX.sharepoint.com\Documents%20partages\qsf.txt';
25 run;
NOTE: DATA statement used (Total process time):
real time 0.00 secondes
cpu time 0.00 secondes
26
27 GOPTIONS NOACCESSIBLE;
28 %LET _CLIENTTASKLABEL=;
29 %LET _CLIENTPROJECTPATH=;
30 %LET _CLIENTPROJECTNAME=;
31 %LET _SASPROGRAMFILE=;
32
33 ;*';*";*/;quit;run;
34 ODS _ALL_ CLOSE;
35
36
37 QUIT; RUN;
38
In english the error is : The specified file is not found
I was just checking on of my jobs and I'm using macro variables for the paths:
x copy "&workloc" "&youtfile ";
This should correspond to the third option you were trying.
The other thing to check is to make sure EG is running the code on the same system where the file exists (otherwise you could create the file directly on SharePoint, or use a common file share).
In the copy command, instead of "Documents%20partages" try "Documents partages". The %20 is just used with http requests.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.