Here is a utility program in link
https://bbs.pinggu.org/thread-2260545-1-1.html
I modify a little to fit your problem.
options cmplib=sasuser.funcs;
proc fcmp outlib=sasuser.funcs.dir;
function diropen(dir $);
length dir $ 256 fref $ 8;
rc = filename(fref, dir);
if rc = 0 then do;
did = dopen(fref);
rc = filename(fref);
end;
else do;
msg = sysmsg();
put msg '(DIROPEN(' dir= ')';
did = .;
end;
return(did);
endsub;
subroutine dirclose(did);
outargs did;
rc = dclose(did);
did = .;
endsub;
subroutine dir_entries(dir $, files
$, n, trunc);
outargs files, n, trunc;
length dir entry $ 256;
if trunc then return;
did = diropen(dir);
if did <= 0 then return;
dnum = dnum(did);
do i = 1 to dnum;
entry = dread(did, i);
/* If this entry is a file, then add to array */
/* Else entry is a directory, recurse. */
fid = mopen(did, entry);
entry = trim(dir) || '\' || entry;
if fid > 0 then do;
rc = fclose(fid);
if n < dim(files) then do;
trunc = 0;
n = n + 1;
files[n] = entry;
end;
else do;
trunc = 1;
call dirclose(did);
return;
end;
end;
else
call dir_entries(entry, files, n, trunc);
end;
call dirclose(did);
endsub;
run;
%let dir="c:\temp";
data _null_;
array files[1000] $ 256 _temporary_;
dnum = 0;
trunc = 0;
call dir_entries(&dir, files, dnum, trunc);
if trunc then put 'ERROR: Not enough result array entries. Increase array
size.';
do i = 1 to dnum;
if find(upcase(files),'.XLS') then
put files;
end;
run;