Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SAS upload/export to Sharepoint

Status
Not open for further replies.

jameshopper

Technical User
Jun 2, 2005
11
GB
Hi,
I'm trying to output a file to our department Sharepoint site, but am coming up with problems. I have added the sharepoint site into my network places and have tried using the Proc Export function:

PROC EXPORT DATA= ruser2.rdu_logout
OUTFILE= " Review Report/Book16.xls"
DBMS=EXCEL2000 REPLACE;
RUN;

but am coing up against this error:


ERROR: Connect: Failure creating file.
ERROR: Error in the LIBNAME statement.
Connection Failed. See log for details.

I know that the libname of the data set is ok, So I'm presuming that it is the libname of the sharepoint it's not liking. I've used the same directory via VBA and had success.

Is there anything I can do to get this working?
Any help would be appreciated.

Thanks

James
 
Hi jameshopper,

I upload a lot of my SAS reports to our intranet site, but i think the method your using above wont work as you might need FTP access to the remote site (from the looks of things, its probably an intranet site rarther than a shared network drive).

There are x2 methods of getting your report onto your remote drive (intranet area).

1) You can create the file on the remote server (there are some issues with this though depending on what OS your using, in work we are using Windows XP, and there are a few issues with the FTP process freezing when uploading, Also depending on how large the file is, or how many files you are uploading it might bomb out of the FTP process).

Code:
Filename MyFTP ftp "/sites/CreditReports/CLM/Quality Review Report/Book16.xls"
host="Your.FTP.Address"
user="Username"
Pass="Password";

PROC EXPORT DATA= ruser2.rdu_logout 
OUTFILE= MyFTP 
DBMS=EXCEL2000 REPLACE;
RUN;
filename MyFTP clear;

The above code should work, but again, its depending on what OS your using it on.

2) This is the option we are using the the moment, we have downloaded a free FTP client (NCFTP - ), and use this to FTP the files we need to our remote server.

First Create a new SAS file and put in the below code:-

Code:
%macro ncftp_send_files(
destination = ,
source = ,
host = ,
username = ,
password = ,
local_files = *.*,
log_file = %str(),
batch_file =C:\ncftp.bat
);


option xsync=1;
%let src_len = %sysfunc(length(&source.));
%if "%sysfunc(substr(&source.,&src_len.,1))"="\" %then
%do;
%let source1 = %sysfunc(substr(&source.,1,&src_len.-1));
%put NOTE: The source macro variable was changed from &source. to &source1.;
%end;
%else 
%do;
%put NOTE: Did not change the source macro variable.;
%let source1 = &source.;
%end;
%if &log_file. ne %str() %then
%do;
x "del &log_file.";
%end;

filename ncftpbat "&batch_file.";
data _NULL_;
file ncftpbat;
x = '"C:\Program Files\NcFTP\ncftpput"' || " -u &username. -p &password. -R " || 
%if &log_file. ne %str() %then %do; "-d &log_file. " || %end;
"&host. " || '"' || "&destination." || '" "' || "&source1." || '"';
put x;
run;

x "&batch_file.";
option xsync=0;

%mend ncftp_send_files;

Save it as NCFTP_Upload.sas

Then you can use the above macro code to upload any files you need by doing the following:-

Code:
PROC EXPORT DATA= ruser2.rdu_logout 
OUTFILE= "c:\Book16.xls" 
DBMS=EXCEL2000 REPLACE;
RUN;

%include 'Location of NCFTP_Upload.sas file';
%ncftp_send_files(destination = sites/CreditReports/CLM/Quality Review Report/,
source = c:\Book16.xls,
host = Your.FTP.Address,
username = username,
password = password,
log_file = c:\log.txt
);

Hope the above helps.

Robbie
 
I export to our Sharepoint site daily. I mapped to the site through my computer...so instead of:

PROC EXPORT DATA= ruser2.rdu_logout
OUTFILE= " Review Report/Book16.xls"
DBMS=EXCEL2000 REPLACE;
RUN;

the outfile looks like this:

PROC EXPORT DATA= ruser2.rdu_logout
OUTFILE= "\\mysharepointsite\sites\CreditReports\CLM\Quality Review Report\Book16.xls"
DBMS=EXCEL2000 REPLACE;
RUN;

Works great. You'll need to have contributor rights to the Sharepoint site to be able to map to it thought My Computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top