BookmarkSubscribeRSS Feed
lmq1220
Fluorite | Level 6

Is there anyone who has experience with converting from FTP to SFTP?

I need make the following code to work by using SFTP.

 

data scr;

Length x $100.;

x='OPEN ORA_WSMOD';                             output; /* FTP SERVER*/

x='xxxxx';                                output; /* USERNAME*/

x='xxxxxx';                               output;/* PASSWORD*/

x='cd ftp_out';                                 output; /* FTP-FOLDER*/

x='lcd c:\temp';                          output; /* OUTPUT FOLDER*/

x='PUT filename1.txt';               output; /* The filename */

x='PUT filename2.txt';              output; /* Another filename*/

x='quit';                           output;

run;

 

data _null_;

set  WORK.SCR                                     end=EFIEOD;

%let _EFIERR_ = 0;

%let _EFIREC_ = 0;

file 'c:\temp\scr.txt' delimiter='09'x DSD DROPOVER lrecl=32767;

format x $100. ;

if _n_ = 1 then

do;

end;

do;

EFIOUT + 1;

put x $ ;

;

end;

if _ERROR_ then call symput('_EFIERR_',1);

If EFIEOD then

call symput('_EFIREC_',EFIOUT);

run;

 

option XWAIT XSYNC;

X 'ftp -s:c:\temp\scr.txt';

6 REPLIES 6
ChrisHemedinger
Community Manager

Is there a reason that you're not using FILENAME FTP?  That might be a little more straightforward to code.


There is also a method for FILENAME SFTP.  As this involves a secure connection, you need an SSH client. From the doc:

 

You must have the applicable client software installed to use the SFTP access method. The SFTP access method supports only the following SSH clients.

  • OpenSSH – UNIX
  • PUTTY – Windows

 

 

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
lmq1220
Fluorite | Level 6

Thank you very much for your reply,Chris.

 

I have just installed software Putty on my computer, Is there any special configuration that Putty should have before i can make SFTP to work?

 

Thanks a lot in advance.

lmq1220
Fluorite | Level 6

 

 

Maybe the SFTP server SAS is connecting to should also have software Putty in order to make my sas program working?

 

ChrisHemedinger
Community Manager

You definitely need Putty to be installed wherever SAS is running, so if your SAS session is on a remote Windows machine, you'll need the SSH client to be there. 

 

I assume that whatever FTP endpoint you're connecting to is already running an SFTP server to support secure connections/transmissions.

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
lmq1220
Fluorite | Level 6

Thanks for your reply again, Chris.

 Is there any special configuration that Putty should have before i can make SFTP to work or i do not know if i have gotten the right version of Putty?

see the attached file( Putty configuration on my computer)

 

Best regards Mei

ChrisHemedinger
Community Manager

 

Yes, there are a few steps -- since you asked, I decided to check in our SAS Tech Support notes.  I think that everything is documented here:

 

Configuring SSH Client Software in UNIX and Windows Environments for Use with the SFTP Access Method...

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 3222 views
  • 3 likes
  • 2 in conversation