Hello,
I am trying to use SAS to FTP an XLSX file that I create via SAS.
I have a SAS code that I use to prepare a dataset that I then save and excel (XLSX) file. I need to FTP these file over every week, I want to set up an automated process that runs the data every week (this I already have set up) and in the automated process I would like to use SAS to FTP the XLSX file it prepares.
I have the host, user and pass. There is a folder (mailbox path) as well that I would like to use.
I tried using the below code that I found in the forum (the user, host, pass is censored, so is the 'mailboxpath') but the below didn't work. There was no log error either for me to troubleshoot the error.
Suggestions on what other code I can use (if the below code is not the way to go)
%let user=XXXX; %let host=YYYY; %let pass=ZZZZZ; filename outdir ftp 'mailboxpath' dir new host="&host" user="&user" pass="&pass" ; data _null_; set X.data ; file outdir('C:\Users\name\toexport.xlsx') xlsx ; run;
I thought you want to move the XLSX file. Your data step is reading a SAS dataset and trying to write a text file. Note that the FILE statement does not support the XLSX engine. The XLSX engine only works when defining a LIBNAME.
What is the name of the existing XLSX file on the SAS host that you want to move to the remote host using FTP protocol?
Do you really want to use the FTP protocol? Most hosts now require you to use the more secure SFTP protocol instead.
Please check if you are able to access the site successfully via FTP.
You should be able to login and get the root directory with the following code.
If you are using a router, don't forget to specify passive mode.
filename dir ftp '' ls user="&user" host="&host" pass="&pass";
data _null_;
infile dir;
input;
put _INFILE_;
run;
If you simply want to upload the file to ftp, you can use command prompt or powershell script to upload and run it with x command.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: