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

 

 

 

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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.

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.
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...

It's time to register for SAS Innovate! Join your SAS user peers in Las Vegas on April 16-19 2024.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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