I wanted to export SAS dataset from SAS into FTP. I can export csv file (or txt file) using the following command:
%macro export_to_ftp(dsn= ,outfile_name= );
Filename MyFTP ftp "&outfile_name."
HOST='ftp.site.com'
cd= "&DATA_STRM/QC"
USER=&ftp_user.
PASS=&ftp_pass.;
PROC EXPORT DATA= &dsn. OUTFILE= MyFTP DBMS=%SCAN(&outfile_name.,2,.) REPLACE;
RUN; filename MyFTP clear;
%mend;
%export_to_ftp(dsn=lib1.dataset ,outfile_name=dataset.csv);
But couldn't use it to export SAS dataset. Can anybody please help me.
Thank you!
PROC EXPORT is not used to export SAS datasets, it's used to convert SAS datasets to other formats. You normally wouldn't use the FTP filename method to transfer SAS datasets; you would either use SAS/CONNECT if you are intending to transfer from one SAS machine to another (if you license SAS/CONNECT and want help with this, please say so), or use normal (OS) FTP processes to transfer the file. It is technically possible to use the FTP filename method to transfer a SAS file (as a binary file, reading then writing byte-by-byte) but that's error-prone and overly complicated.
The best method if you're using SAS to drive the process is to write a FTP script in your OS, and call that using x or %sysmd, passing the filename as an argument. If you include information about your operating system, something could be easily drawn up to help you out.
Note: if you're on a server, you need to verify that you have 'x' permission; that's often locked down. If you do not, you may not be able to run this entirely from SAS.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With