DATA Step, Macro, Functions and more

Create a csv file in SFTP server

Reply
Contributor
Posts: 70

Create a csv file in SFTP server

Hi,

 

I want to create one of the sas datset in SFTP server in CSV format.I tried below test code to create file in SFTP server,but i could not connect to FTP server.

 

I also tried to connect to SFTP with libname statement but even that not work.

 

FILENAME targetSFTP "/xx/test.csv" HOST = 'xx-xx.xx.xx.com' DEBUG;

data _null_;

file target;

do i=1 to 10;

put i=;

end;

run;

 

Please help me to get it done in two ways with filename and libname.

 

Thanks in advance

 

regards,

ravi

 

Super User
Posts: 7,766

Re: Create a csv file in SFTP server

To use filename sftp, password-free authentication needs to be in place. Make sure that you have public/private key authentication set up for the userID's involved.

 

Also post the log for steps that don't work. Without the log, everything else is guesswork.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 70

Re: Create a csv file in SFTP server

Posted in reply to KurtBremser

Hi Kurt,

Thans for your quick response.I did not understand this public and private keys.

 

But i have username and password for this SFTP server.I read that we should not use password for SFTP server so i have run only with username.

Please find the below log file

 

22 GOPTIONS ACCESSIBLE;

23 FILENAME target1 SFTP USER='xx' HOST = 'xx.xx.xxx.com' DEBUG;

24 data _null_;

25 file target1;

26 do i=1 to 10;

27 put i=;

28 end;

29 run;

NOTE: Connecting to xxxx-xx.xxt.xx.com...

NOTE: The file TARGET1 is:

Filename

NOTE: ssh: connect to host xxxx.xx.xxt.com port 22: Connection timed out

NOTE: 10 records were written to the file TARGET1.

The minimum record length was 3.

The maximum record length was 4.

NOTE: DATA statement used (Total process time):

real time 1:03.21

cpu time 0.02 seconds

 

 

Super User
Posts: 7,766

Re: Create a csv file in SFTP server

You have to set up password-free authentication, or SFTP won't work from SAS.

Do a google search for

ssh key-based authentication

and you will find all necessary information.

 

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Ask a Question
Discussion stats
  • 3 replies
  • 306 views
  • 0 likes
  • 2 in conversation