Hi, I would like to create a list of information about every file that is readable in a catalog/subcatalog within specified directory. The informations i want to get are: - Create date, modification date, owner, size and path to the file. I managed to create a code: %macro list_files(path);
%local fileref did memcnt i fid rc moddate crdate owner size filepath fullpath;
data file_into;
length filepath $256 filename $256 owner $100 crdate $30 moddate $30 size 8;
format size comma20.0;
stop;
run;
%let rc=%sysfunc(filename(filrf,&path));
%let did=%sysfunc(dopen(&filrf));
%if &did > 0 %then %do;
%let memcnt = %sysfunc(dnum(&did));
%do i = 1 %to &memcnt;
%let filename = %sysfunc(dread(&did, &i));
%let fullpath = &path/&filename;
%if %sysfunc(fileexist("&fullpath")) %then %do;
%let fid = %sysfunc(fopen("&fullpath"));
%if &fid > 0 %then %do;
%let size = %sysfunc(input(finfo(fid, 'File Size (bytes)'), 20.));
%let crdate = %sysfunc(finfo(fid, 'Create Time'));
%let moddate = %sysfunc(finfo(&fid, 'Last Modified'));
%let owner = %sysfunc(finfo(fid, 'Owner Name'));
data file_into;
set file_into;
filepath = "&fullpath";
filename = "&filename";
owner = "&owner";
size = "&size";
crdate = "&crdate";
moddate = "&moddate";
output;
if last then do;
call symput('file_count', _N_);
end;
run;
%let rc = %sysfunc(fclose(&fid));
%end;
%end;
%else %do;
%list_files(&fullpath);
%end;
%end;
%let rc = %sysfunc(dclose(&did));
%end;
%else %do;
%put "ERROR: Could not open directory &path";
%end;
%mend list_files; Unfortunately, there is no result at all. Sometimes when the catalogs name is big I get a note: "In a call to the FOPEN routine, the fileref (...) exceeds 8 characters, and will be truncated. But even if there is a file (at the top level of specified &path) I get no information back about it. Maybe someone ever tried making such a code and would be open to help me.
... View more