The purpose is as in title.
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 prod=access;
*%let prod=iml;
%let prod=core;
data _null_;
array files[1000] $ 256 _temporary_;
dnum = 0;
trunc = 0;
call dir_entries("%sysget(sasroot)\&prod.\sample", files, dnum, trunc);
if trunc then put 'ERROR: Not enough result array entries. Increase array
size.';
do i = 1 to dnum;
put files[i];
end;
run;
**********************************************;
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\append.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\armsamp.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\biorythm.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg01r01.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg02r01.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg05r01.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\bpg07r01.sas
.........................
SNIPPED
.........................
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\univar2.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\univar3.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\update2.sas
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\User.gif
C:\Program Files\SASHome\x86\SASFoundation\9.3\core\sample\wordfreq.sas
NOTE: DATA statement used (Total process time):
real time 4.93 seconds
cpu time 0.26 seconds