Use the file functions fopen, foptnum, foptname and finfo:
filename fref 'D:\testing.xlsx';
data fileinfo;
fid = fopen("fref");
do i = 1 to foptnum(fid);
opt = foptname(fid,i);
val = finfo(fid,opt);
output;
end;
run;
One of the information items will contain what you look for. Be aware that the names and values are specific to the operating system and the system's locale.
data have;
input filename$1024.;
cards;
D:\testing.xlsx
;
data want;
set have;
rcs = filename("fileref", filename);
fid=fopen('fileref');
Bytes=finfo(fid,'File Size (bytes)');
crdate=finfo(fid,'Create Time');
moddate=finfo(fid,'Last Modified');
run;
proc print;
run;
As I said, the optnames are locale- and system-specific. In my case (AIX, German), there is no "Create Time" at all (it is misleading information anyway), but a "Zuletzt geändert" (modification time).
This is why I strongly prefer to use system commands for this, as they can be directed by parameters (see GNU ls) to return specific information in a specific format (like ISO-timestamps), independent of the current environment.
I agree with your points, Thank you for your valuable comment.
Please post the log. "Does not work" on its own is USELESS.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.