Hello,
I'm connecting throught SFTP to a server using:
filename fileList sftp '/init/folder/' host="hostname.local" user="user" optionsx='-i "E:\SAS WORK\mykey.ppk" -pw "pass" ' lsa;
i'm trying to get the list of all files in the folder, so i can read the lastest one. But the problem is that the remote server contains 35 files and i'm just getting 32. When i connect through Filezilla to the same server with the same user i can see the 35 files.
How are you reading the output generated by your FILELIST fileref?
Show the data step that you used to read it as there are things that can make the data step skip lines in the file. The most obvious one being not using the TRUNCOVER option on the INFILE statement.
Example:
data test;
input id string $100.;
cards;
1 abc
2 def
3 ghi
4 jkl
5 mno
;
74 data test; 75 input id string $100.; 76 cards; NOTE: LOST CARD. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 82 ; id=5 string= _ERROR_=1 _N_=3 NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: The data set WORK.TEST has 2 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
It might help to show the names of some of the files your code doesn't find.
IF any of the files you didn't get happen to have names that start with a dot such as .xauthority then use the LS option instead of LSA.
The files are like this.
1DIARIOCAN.2023178.T060520.txt
1DIARIOCAN.2023178.T092530.txt
1DIARIOCAN.2023178.T110530.txt
if i run the process at 12 pm, the data step only bring: the first to files but the one at 11 am is left out.
How are you reading the output generated by your FILELIST fileref?
Show the data step that you used to read it as there are things that can make the data step skip lines in the file. The most obvious one being not using the TRUNCOVER option on the INFILE statement.
Example:
data test;
input id string $100.;
cards;
1 abc
2 def
3 ghi
4 jkl
5 mno
;
74 data test; 75 input id string $100.; 76 cards; NOTE: LOST CARD. RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 82 ; id=5 string= _ERROR_=1 _N_=3 NOTE: SAS went to a new line when INPUT statement reached past the end of a line. NOTE: The data set WORK.TEST has 2 observations and 2 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds
Hello Tom,
Thanks for your answer. Here is the code
filename fileList sftp '/init/folder/' host="hostname.local" user="user" optionsx='-i "E:\SAS WORK\mykey.ppk" -pw "pass" ' lsa;
data Files;
infile fileList ;
input fileName $255. ;
run;
thanks
Juan R Gomez
Hello again Tom.
You're right, with the truncover option, i'm getting all the files.
Thanks a lot.
Juan R Gomez
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.