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
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.
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
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.
Hi I have done with key pair setup and I have to read the data iin CSV file from sub directories. Please suggest.
filename my data sftp "/Dir/RPTS/qtr/&CSV_file"
host="hostname" user="username";
ERROR: Directory or file doesnot exist
Do we have any alternate method in SAS instead of USing SFTP in SAS
filename my data sftp "/Dir/RPTS/qtr/&CSV_file"
host="hostname" user="username";
This is an alternate solution:
If you are trying to have your files in SFTP server, but in SAS if you have only access to Local then use WinSCP to drag and drop files from local machine to your SFTP.
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.
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.