HermannHH
HermannHH

Reputation: 1772

Detecting the latest modified date in a folder using SAS

I am writing a program that needs to run every day. In a specific section of the program, all datasets in a specific library will be appended into one dataset in another library.

My plan is to scan the first library to retrieve the latest modified time and then compare this to the last modified time of the appended dataset in the second library. The script will only be executed if the last modified date in the first library is greater than that in the second library.

I have found a way to do this for a specific dataset using the PROC DATASET command, but since I have more than 200 individual datasets in my first library, I'm trying to find a more efficient solution.

I also found the following solution that I can't seem to get right (Keeps on saying that the directory can't be found on this machine, even though I'm using the exact same path for a LIBNAM assignment):

data _null_;
 infile 'dir \\path\to\my\folder\/o-d /b' pipe obs=1;
 input ;
 call symputx('last',_infile_);
run;

I am using a Windows system by the way.

Upvotes: 2

Views: 6470

Answers (1)

in_user
in_user

Reputation: 1958

You can use SAS dictionary tables to find out the last modified date of the tables residing in a certain library.

    proc sql;
    create table dataset_1 as select libname,memname, modate 
from dictionary.tables where libname="your_library";
    quit;

Upvotes: 2

Related Questions