BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
whymath
Barite | Level 11

I am going to analyze a batch of SAS program file and I am stucked in getting the last modified time of program files. I have thought about X command but it was too inefficient.

I just find when I use infile statement:

 

data test;
  infile 'D:\test.txt' truncover;
  input ;
run;

 

Log shows the last modified time:

NOTE: The infile 'D:\test.txt' is:
        Filename=D:\test.txt,
        RECFM=V,LRECL=32767,File Size (bytes)=7,
        Last Modified=2021/1/26 15:25:48,
        Create Time=2021/1/26 15:25:42

As you can see, log window shows the infomation of file as a NOTE. However, my wish output is a variable filled with Last Modified Time.

Is there some option to get it while using `infile` statement? Surely, Other efficient ways are welcomed, too.

1 ACCEPTED SOLUTION

Accepted Solutions
Shmuel
Garnet | Level 18

Check next code:

filename fname 'D:\test.txt' truncover;
data _null_;
    fid = fopen('fname');
    if fid then do;
       fattr = finfo(fid,'Last Modified'); 
       lm = input(fattr,datetime18.);  /* lm = Last Modified datetime */
       /* add any other required code */
   end;
   else put '*** Cannot open the file ***';
run;
      

View solution in original post

4 REPLIES 4
Shmuel
Garnet | Level 18

Check next code:

filename fname 'D:\test.txt' truncover;
data _null_;
    fid = fopen('fname');
    if fid then do;
       fattr = finfo(fid,'Last Modified'); 
       lm = input(fattr,datetime18.);  /* lm = Last Modified datetime */
       /* add any other required code */
   end;
   else put '*** Cannot open the file ***';
run;
      
whymath
Barite | Level 11
Very useful and quick, thanks.
andreas_lds
Jade | Level 19

You could use something like:

filename chk "YOUR_FILE";

data moddates;
   set sashelp.vextfl;
   where upcase(fileref) = 'CHK';

   keep xpath modate;
run;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 4 replies
  • 2155 views
  • 3 likes
  • 3 in conversation