BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
radhames_gomez
Calcite | Level 5

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.  

 

data Files;
infile fileList ;
input fileName $255. ;
run;
 
How can i solve this issue, because my process has to look for the last file every one hour?
 
best regards,.
 
Juan Radhamess

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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

View solution in original post

5 REPLIES 5
ballardw
Super User

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.

 

 

radhames_gomez
Calcite | Level 5

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.

 

 

Tom
Super User Tom
Super User

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
radhames_gomez
Calcite | Level 5

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

radhames_gomez
Calcite | Level 5

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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 738 views
  • 0 likes
  • 3 in conversation