BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
naveenraj
Quartz | Level 8

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

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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

View solution in original post

7 REPLIES 7
Reeza
Super User

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.

naveenraj
Quartz | Level 8

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

Reeza
Super User

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. 

naveenraj
Quartz | Level 8

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

Kurt_Bremser
Super User

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

naveenraj
Quartz | Level 8

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

Kurt_Bremser
Super User

@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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 7 replies
  • 6251 views
  • 3 likes
  • 3 in conversation