DATA Step, Macro, Functions and more

FTP within SAS program

Reply
Super Contributor
Posts: 673

FTP within SAS program

Hello All,

  How do I FTP a file from one directory to other within SAS in UNIX?

  FTP needs to be done only if I have an error free log.

Thanks,

Super User
Posts: 19,870

Re: FTP within SAS program

proc copy and proc datasets don't work for moving files in UNIX?

Super Contributor
Posts: 673

Re: FTP within SAS program

The files I create are to be sftp'd to HADOOP process.So I cannot Sftp sas datasets.I need to sftp a delimited file created from SAS datasets.

Super Contributor
Posts: 1,636

Re: FTP within SAS program

Hi,

I am curious why you never mark your questions as answered? No one has provided you with a correct answer so far?

Super Contributor
Posts: 673

Re: FTP within SAS program

I usually reply saying thanks for by Liking their response.

Trusted Advisor
Posts: 2,116

Re: FTP within SAS program

SASPhile,

Liking is nice, but checking a response to a question as answered has several advantages

-- the respondent gets "credit" in the forum for their expertise

-- we readers get to see the answer adjacent to the original question, so it is easier to follow (some of the thread get very long).

-- an icon is marked next to the thread that it has been answered.  That helps those with limited time to use it most productively.

Hope that helps,

Doc

Super Contributor
Posts: 673

Re: FTP within SAS program

Where to check a response as answered?

SAS Employee
Posts: 3

Re: FTP within SAS program

Have you tried the filename statement with ftp access method?  Here's doc, SAS(R) 9.3 Statements: Reference and example.

This example reads the file ftpmem1 from a directory on a UNIX host, and writes the file ftpout1 to a different directory on another UNIX host.

filename indir ftp '/usr/proj2/dir1' DIR host="host1.mycompany.com"

user="xxxx" prompt; filename outdir ftp '/usr/proj2/dir2' DIR FILEEXT

host="host2.mycompany.com" user="xxxx" prompt;

data _null_; infile indir(ftpmem1) truncover; input; file outdir(ftpout1); put _infile_; run;

The file ftpout1 is written to /usr/proj2/dir2/ftpout1.DATA. Note that a member type of DATA is appended to the ftpout1 file because the FILEEXT option was specified in the output file's FILENAME statement.

Note: The DIR option is not needed for some ODS destinations.

The following example writes an output file and transfers it to an ODS-specified destination. The DIR option is not needed.

filename output ftp "~user/ftpdir/"

host="host.fyi.company.com" user="userid" pass="userpass"

recfm=s debug;

ods html body='body.html' path=output; proc print data=sashelp.class;run;

To export multiple graph files to a remote directory location, the DIR option must be specified in the FILENAME statement. Accordingly, when creating external graph files with the ODS HTML destination, two FILENAME statements are needed: one for the HTML files, and one for the graph files. The following example illustrates the need for two FILENAME statements.

filename output1 ftp "~user/dir" fileext

host="host.unx.company.com" user="userid" pass="userpass"

recfm=s debug; filename output2 ftp "~user/dir" dir fileext

host="host.unx.company.com" user="userid" pass="userpass"

recfm=s debug; ods html body='body.html'

path=output1 gpath=output2 frame='frames.html' contents='contents.html';

proc gtestit; run; quit; ;

Trusted Advisor
Posts: 1,301

Re: FTP within SAS program

Use PROC HADOOP and avoid the FTP stuff...

http://support.sas.com/documentation/cdl/en/achadoop/65227/PDF/default/achadoop.pdf

sample_config.xml

<configuration>

   <property>

      <name>fs.default.name</name>

      <value>hdfs://xxx.us.company.com:8020</value>

   </property>

   <property>

      <name>mapred.job.tracker</name>

      <value>xxx.us.company.com:8021</value>

   </property>

</configuration>

filename cfg "C:\Users\sasabc\hadoop\sample_config.xml";

proc hadoop options=cfg username="sasabc" password="sasabc" verbose;

   hdfs copyfromlocal="C:\user\sasabc\testdata.txt"

   out="/users/sasabc/Hadoop/testdata.txt" overwrite;

run;

Ask a Question
Discussion stats
  • 8 replies
  • 539 views
  • 2 likes
  • 6 in conversation