Automate reading the SAS files from SFTP and run the daily program to read in the data

Reply
Occasional Contributor
Posts: 12

Automate reading the SAS files from SFTP and run the daily program to read in the data

Hello

 

I download data from different vendors posted on SFTP every day. I have written a general program for each data as data layout structure for each data is same. So, everyday, I download and copy the data to a particular folder, run the program to read in the data and save the data to a particular folder. Is there any method to automate this so that I don't have to do the same boring stuff every day. So, basically I want a solution where the program will check if any new data is available, download it and save it to a particular folder, run the program at a particular time of the day and then save the SAS data to a folder. Please let me know.

 

Thanks

 

Super User
Posts: 17,840

Re: Automate reading the SAS files from SFTP and run the daily program to read in the data

Occasional Contributor
Posts: 12

Re: Automate reading the SAS files from SFTP and run the daily program to read in the data

Hey Reeza 

 

Thanks for the link. I am using this code:

 

FILENAME DIR FTP '       ' LS USER = '********************' HOST = '**************************' PASS = '######';

RUN;

 

In the log, it says the connection timed out. Since I am using WINSCP software to download the files, is it creating a problem because I didn't mention any software connection over here and it is trying to search the host on web.

 

Thanks

Chandan Mishra

Super User
Posts: 17,840

Re: Automate reading the SAS files from SFTP and run the daily program to read in the data

WinSCP connects to a server using the same host/user and password information. Did you put in the same values from WinSCP into the FILENAME statement. 

 

Not sure why you think you need to have a 'software connection'. The idea should be to bypass WinSCP to get the file directly.

Occasional Contributor
Posts: 12

Re: Automate reading the SAS files from SFTP and run the daily program to read in the data

I am still trying to read in the files using the method available on SAS community. I have used all the processes but not able to log into the SFTP system even though I can log in normally. I will keep you posted.

Super User
Super User
Posts: 6,500

Re: Automate reading the SAS files from SFTP and run the daily program to read in the data

You need to SFTP instead of FTP if you are accessing an SFTP server.

 

http://documentation.sas.com/?docsetId=lestmtsref&docsetTarget=p0xln1fiwsr340n1xxf4mkmfxp6f.htm&docs...

 

Even then you might need to do something to allow you to connect.  Sign on to the host where SAS is running and see if you can connect to the SFTP host using the sftp command line program.

 

You might need to automate the download parts by calling the sftp commands via the SYSEXEC or X commands or by using PIPE engine on a filename.  

 

You also might want to look into using curl to retrieve the files instead of native sftp commands.  That should give you a lot more flexibility in automating the login process.

Ask a Question
Discussion stats
  • 5 replies
  • 134 views
  • 0 likes
  • 3 in conversation