www.sas.com > SAS UK > In the Know Homepage Search | Contact Us    
SAS UK Newsletter Banner SAS - The power to know(tm)  

How can I read a text file from a remote host into a local SAS session using the FTP protocol?


The filename FTP access method allows you to access remote files using the FTP protocol from FTP servers.

In the example below the file test.txt has been accessed using FTP and read into a local SAS dataset test.

filename myfile ftp 'test.txt' cd='/unix/directory/specification'
  host='Network.Name.Remote.Host'
user='Username'
pass='Password'
recfm=v ;
data work.test ;
   length var1 $ 200 ;
    infile myfile ;
   input var1 ;
   put _infile_ ;
run;
 

Here we are creating a text file called test2.txt on a remote Unix host using FTP.

filename create ftp 'test2.txt' cd='/unix/directory/specification'
  host='Network.Name.Remote.Host'
user='Username'
pass='Password'
recfm=v ;
data _null_ ;
   file create ;
   do i=1 to 10 ;
      put i= ;
   end ;
run ;
 

Note: The above code has been tested using SAS 8.2 on the Windows operating system.