My preferred method is to use an external command to retrieve the information:
%let library=sasuser;
%let library_path=%sysfunc(pathname(&library));
filename dirlist pipe "ls -l &library_path/";
data attributes;
label
number = '#'
dsname = 'Name'
memtype = 'Member Type'
size = 'File Size'
mod_date = 'Last Modified'
mod_time = 'Time'
permissions = 'Access Permission'
;
infile dirlist;
input
permissions :$10.
links :3.
user :$8.
group :$8.
size :15.
_month :$3.
day :2.
year_time :$5.
dsname :$254.
;
retain number 0;
dsname = scan(dsname,-1,'/');
extension = scan(dsname,2,'.');
dsname = scan(dsname,1,'.');
if permissions ne 'total'; /* removes header */
if extension in ('sas7bdat','sas7bvew','sas7bcat');
length memtype $10;
select (extension);
when ('sas7bdat') memtype = 'DATA';
when ('sas7bvew') memtype = 'VIEW';
when ('sas7bcat') memtype = 'CATALOG';
otherwise;
end;
month = month(input('01' !! _month !! '1960',date9.));
if length(year_time) = 5
then do;
if month > month(today())
then year = year(today()) - 1;
else year = year(today());
mod_time = input(year_time,time5.);
end;
else do;
year = input(year_time,4.);
mod_time = 0;
end;
mod_date = mdy(month,day,year);
format
mod_date yymmddd10.
mod_time time5.
;
number + 1;
keep number dsname memtype size mod_date mod_time permissions;
run;
proc print data=attributes noobs label;
var number dsname memtype size mod_date mod_time permissions;
run;