Hi All,
I need to transfer some files from SFTP server to SAS server on daily basis based on the SFTP date and time.
For example i need to transfer all the files for date 14th May or 17th May.
Can someone please help how i can access the SFTP date time from SAS.
With "mget" i can pull all the file available in SFTP but i want to pull the file only for the specific day.
You should be able to use the DIR option to get a listing of files in the folder. You could then parse that listing to determine which files have the dates you want and "get" them by name.
Before you even start using SAS get your SFTP command right to only select the files you're after. There will be a lot of examples when Googling the moment you take SAS out of the picture.
Once you've got the SFTP command as needed you then can call it from within SAS using Filename Pipe.
This example reads the files test.dat
and test2.dat
from a directory on the remote host.
filename infile sftp '/users/xxxx/' host="unixhost1" dir;
data _null_;
infile infile(test.dat) truncover;
input a $25.;
infile infile(test2.dat) truncover;
input b $25.;
run;
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.
Ready to level-up your skills? Choose your own adventure.