Reputation: 444
I am trying to write some code that will look at all the datasets in a libname and bring back the created date of the most recently created file.
I have googled this for an entire day and cannot find a way to do this. I know that ATTRN can determine the created date of a dataset:
%let data_set = libname.data_set_name;
%let dsid = %sysfunc (open(&data_set));
%let create_date = %sysfunc(attrn(&dsid, crdte));
But there seems to be no way to make it look at multiple datasets so that a max date can be determined.
Can anyone please help?
Upvotes: 3
Views: 3060
Reputation: 444
OK, so I eventually found this bit of code in "Get Control of Your Input: Refer to Multiple Data Files Efficiently" a paper by Zhongping Zhai, Bloomington, IL and this works nicely for me:
proc sql;
create table all_datasets as
select memname, crdate
from dictionary.tables
where libname="LIBNAME" and memname like "DSN%";
quit;
Hope this helps someone else too!
Upvotes: 5