Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting SAS Data into FTP using SAS

Tags:

sas

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!

like image 749
Beta Avatar asked Dec 09 '22 14:12

Beta


1 Answers

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.

like image 158
Joe Avatar answered Dec 30 '22 11:12

Joe