Consider using the DATA step and the INFILE parameters EOV= to detect the new-file start (after reading the first file). And if you need know the current file-name, use the FILENAME= parameter (after declaring a LENGTH for ).
Here's an example to read all files that start with FRED*.TXT -- the multiple PUTLOG statements demonstrates SAS behavior with the EOV= being set on the first-record instance, except for the _N_=1 condition:
data _null_;
length fileinfo $255;
infile 'c:\temp\fred*.txt' end=eof eov=eov filename=fileinfo;
input @;
putlog '>diag-before>' / _all_;
if eov=1 then do;
recnum=0;
eov=0;
end;
recnum+1;
putlog '>diag-after>' / _all_;
run;
Review the SAS 9.2 INFILE statement parameter documentation for more details.
Scott Barry
SBBWorks, Inc.