Sorry, forgot a line in the program, the filename statement:
%let dir=/usr/local/tmp; /* full path of directory with files */
Filename indir "&dir";
data members;
did=dopen('indir');
do _n_=1 by 1;
fname=dread(did,_N_);
if fname=' ' then leave;
/* you can also put criteria here, instead of in the next datastep,
only LIKE is very nifty and only available with WHERE */
output;
end;
keep fname;
run;
data hcount;
set members;
where upcase(fname) like '%.TXT'; /* or whatever criteria you want */
path=cats("&dir",'/',fname); /* may have to change / to \ for Windows */
infile dummy filevar=path;
input;
count=count(_infile_,'09'x);
keep fname count;
run;