BookmarkSubscribeRSS Feed
xiaobin
Calcite | Level 5

Hello,

I have a program that only needs to be executed whenever a newer data file is available. The data file is in text format. Instead of keeping a record of the older version and run a compare to find if the file is any different, I am hoping to be able to capture the modified time of the text file (so I can skip touching the data to just find out if the file has been updated). Is there a way to get the last modified time for text files through SAS?

 

Or are there other better/alternative approaches I could consider?

 

Thank you!

Xiaobin

 

4 REPLIES 4
xiaobin
Calcite | Level 5

@Kurt_Bremser FINFO gives me exactly what I want. Thank you!!

HB
Barite | Level 11 HB
Barite | Level 11

I think your logic is:

 

SAS program exists

Run program

   If text input file last modified date is different than the last time this program ran

       Go manipulate stuff

   if not

        Just quit and maybe provide a feedback message

 

 

I think that logic depends on two things, the first being what you asked which is grabbing the file date and the second being storing that date someplace to be able to compare it the next time the program is run.

 

I think the first part is:

 

filename fileref 'path\aaa.txt';                                                                                                          
data a(drop=fid);                                                                                                                       
   infile fileref truncover obs=1;                                                                                                       
   fid=fopen('fileref');                                                                                                                 
   moddate=finfo(fid,'Last Modified');                                                                                                   
run;    

proc print;                                                                                                                             
run;

 

This make a dataset in WORK that contains the modified date.  It looks like 12Jan2017:10:25:14.

 

I think then if you wrote that dataset out to a text file to store that date, when you ran your program again you could grab the incoming date, compare to the written out date, and logically see where you wanted to go.

 

HTH.

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2593 views
  • 0 likes
  • 3 in conversation