Desktop productivity for business analysts and programmers

Can SAS use SFTP method to import a file from external network

Accepted Solution Solved
Reply
Contributor
Posts: 54
Accepted Solution

Can SAS use SFTP method to import a file from external network

Hi,

 

I was going through the documentation for sas on sftp http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p0xln1fiwsr340n... Here it is mentioned that we can import files from differant systems. Is it possible to import the files present on adifferant network through sftp method. 

 

I have a requirement where i need to load a file in sas after fetching the file directly which will be present in another network(outside my organisation).

 

Regards,

Naveen


Accepted Solutions
Solution
‎04-13-2016 05:05 AM
Super User
Posts: 7,445

Re: Can SAS use SFTP method to import a file from external network

For SFTP from SAS to work, you need to setup the connection externally first:

- log on to the SAS server with the userID that will be used to run SAS

- open a SFTP/SSH connection to the target host; this depends on the operating system of the SAS host: Windows uses PuTTY, UNIX uses ssh from the OpenSSH suite

- confirm the target host's key so that it will be included in your known_hosts database

- transfer your public key to the remote host and insert it there, according to the host type; see the SSH software's documentation where keys are stored and can be found on both servers

 

While doing this, you confirm that you have a connection to the target host (port 22) through the firewalls, have a valid userid and appropriate software there.

Note that setting up the public key in the target host is mandatory, as SAS does not support password authentication with SFTP

 

Once you can do ssh username@host and get a command prompt on the remote host without further inputs, you're set up.

 

Information can be found in Filename SFTP statement

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers

View solution in original post


All Replies
Super User
Posts: 19,167

Re: Can SAS use SFTP method to import a file from external network

You can always use the X or %sysexec command to SFTP the file.

 

You can use Filename to read the file directly - without transferring it
http://support.sas.com/documentation/cdl/en/lestmtsref/68024/HTML/default/viewer.htm#p0xln1fiwsr340n...

 

It seems to depend a bit on your setup though.

Contributor
Posts: 54

Re: Can SAS use SFTP method to import a file from external network

I need to know whether we can transfer the file even if it is from outside our network.

Super User
Posts: 19,167

Re: Can SAS use SFTP method to import a file from external network

This isn't my area of expertise but I think if you can sftp it out of SAS you can in SAS as long as you have someway to connect to the other network. 

 

If if you can't do it via a sftp via putty then you can't in SAS either. 

Contributor
Posts: 54

Re: Can SAS use SFTP method to import a file from external network

I need to know whether we can transfer the file even if it is from outside our network. As the file is present in another network

Solution
‎04-13-2016 05:05 AM
Super User
Posts: 7,445

Re: Can SAS use SFTP method to import a file from external network

For SFTP from SAS to work, you need to setup the connection externally first:

- log on to the SAS server with the userID that will be used to run SAS

- open a SFTP/SSH connection to the target host; this depends on the operating system of the SAS host: Windows uses PuTTY, UNIX uses ssh from the OpenSSH suite

- confirm the target host's key so that it will be included in your known_hosts database

- transfer your public key to the remote host and insert it there, according to the host type; see the SSH software's documentation where keys are stored and can be found on both servers

 

While doing this, you confirm that you have a connection to the target host (port 22) through the firewalls, have a valid userid and appropriate software there.

Note that setting up the public key in the target host is mandatory, as SAS does not support password authentication with SFTP

 

Once you can do ssh username@host and get a command prompt on the remote host without further inputs, you're set up.

 

Information can be found in Filename SFTP statement

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

Re: Can SAS use SFTP method to import a file from external network

Dear KurtBremser,

 

Correct me if i am wrong. I am completely new to SFTP, so need your assistance.

You are saying that with sas we can import file from an external network(outside my network) using SFTP. there wont be any issues, once proper setup is done?

 

Regards,

Naveen

Super User
Posts: 7,445

Re: Can SAS use SFTP method to import a file from external network


naveenraj wrote:

Dear KurtBremser,

 

Correct me if i am wrong. I am completely new to SFTP, so need your assistance.

You are saying that with sas we can import file from an external network(outside my network) using SFTP. there wont be any issues, once proper setup is done?

 

Regards,

Naveen


Yes. The main point is that you MUST have SSH access from your SAS server to that remote host. If you are prompted to approve the remote server's key when you do ssh servername (or are immediately asked for a password because you already have that key), you have already verified that you can connect to the remote server across all the network hops inbetween. Everything else is configuration work, as I outlined before.

 

One caveat: with SAS 9.2, I had a problem when downloading larger files over a complex WAN connection. Since SAS uses an external tool for SFTP (while FTP is built-in), and tries to read the transferred file concurrently while the download is still in progress, it can run over the current end of the transferred file and terminate a data step with a LOST CARD Note. This forced me to do the SFTP transfer with sftp in a filename pipe and wait for the transfer to finish before reading the transfer file.

This (bug?) may be fixed in later SAS versions.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 968 views
  • 3 likes
  • 3 in conversation