DATA Step, Macro, Functions and more

Unable to import a file from Remote server using SFTP

Reply
Super Contributor
Posts: 435

Unable to import a file from Remote server using SFTP

I'm unable to import a file from Remote server using SFTP. I tried the following code, but the code has failed with the error. I verified SFTP connection from our SAS Grid server and credentials looks fine. I am able to import the file using SFTP client which means I confirm that file exists in the directory.

 

data aaaa;
	a=1;
run;

FILENAME in SFTP '/IN/SNAP/CAT_20170705171730.txt' LRECL=256
	HOST='sftp://babloo_SFTP@b2b.cabdo.com'
	USER='babloo_SFTP'
;

DATA _NULL_;
	INFILE in;
	INPUT HOUSEHOLD_ID;
RUN;

PROC PRINT DATA=_NULL_(obs=10);
RUN;

Snippet from Log:

 

34         DATA _NULL_;
35         	INFILE in;
36         	INPUT HOUSEHOLD_ID;
37         RUN;

2                                                          The SAS System                              08:49 Wednesday, July 5, 2017

NOTE: cd /IN/SNAP
ERROR: Directory or file /IN/SNAP/CAT_20170705171730.txt doesn't exist.
NOTE: The SAS System stopped processing this step because of errors
Super User
Posts: 7,764

Re: Unable to import a file from Remote server using SFTP

Log on to the server with sftp (you do have public/private key authentication enabled?), change to the directory, do a ls there, and then post a copy/paste of the whole process here.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 435

Re: Unable to import a file from Remote server using SFTP

Posted in reply to KurtBremser

sftp> dir
IN
sftp> pwd
sftp> cd /IN/SNAP
sftp> ls
CAT_20170705171730.txt
sftp> pwd
Remote working directory: /IN/SNAP
sftp>

Super User
Posts: 7,764

Re: Unable to import a file from Remote server using SFTP

Reduce the host= in your code to the bare hostname:

FILENAME in SFTP '/IN/SNAP/CAT_20170705171730.txt' LRECL=256
	HOST='b2b.cabdo.com'
	USER='babloo_SFTP'
;

No protocol and/or username necessary and allowed there.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 435

Re: Unable to import a file from Remote server using SFTP

Posted in reply to KurtBremser
I tried this already, but still receiving the same error message.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Posts: 7,764

Re: Unable to import a file from Remote server using SFTP

Well, I tried something similar (filename sftp from a Linux server), and when I added the "sftp://username@" to the host name, I got exactly your error message.

 

Please post the log of the complete step, from filename statement to the ERROR message.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 435

Re: Unable to import a file from Remote server using SFTP

Posted in reply to KurtBremser
28         FILENAME in SFTP '/Babloo_SFTP/IN/SNAP/CAT_20170705171730.txt'
29         		HOST="Babloo_SFTP@b2b.cabdo.com" 
30         	USER='Bablopp_SFTP'
31         	;
32         
33         DATA _NULL_;
34         	INFILE in;
35         	INPUT HOUSEHOLD_ID;
36         RUN;

NOTE: cd /Babloo_SFTP/IN/SNAP/CAT_20170705171730.txt
2                                                          The SAS System                              08:49 Wednesday, July 5, 2017

ERROR: Directory or file /Babloo_SFTP/IN/SNAP/CAT_20170705171730.txt doesn't exist.
NOTE: The SAS System stopped processing this step because of errors.
Super User
Posts: 7,764

Re: Unable to import a file from Remote server using SFTP

WOULD YOU PLEASE CARE TO READ AND IMPLEMENT MY POSTS?

Drop the  "Babloo_SFTP@" from the hostname!!!

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 435

Re: Unable to import a file from Remote server using SFTP

Posted in reply to KurtBremser
I'm still receiving the same error message when I drop 'Babloo_SFTP@'.

##- Please type your reply above this line. Simple formatting, no
attachments. -##
Super User
Posts: 7,764

Re: Unable to import a file from Remote server using SFTP

Since you probably don't want to reveal the real host-/user/filenames so we could test from our SAS (or the server won't be reachable from outside), it's best you open a track with SAS technical support.

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