BookmarkSubscribeRSS Feed
thanikondharish
Calcite | Level 5
I have one file .path is 'D:\testing.xlsx'

How to take above file created date
6 REPLIES 6
Kurt_Bremser
Super User

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.

Sathish_jammy
Lapis Lazuli | Level 10
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;
Kurt_Bremser
Super User

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.

Sathish_jammy
Lapis Lazuli | Level 10

I agree with your points, Thank you for your valuable comment. Smiley Happy

thanikondharish
Calcite | Level 5
This code is not working ,giving zero observations

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 6 replies
  • 886 views
  • 1 like
  • 3 in conversation