Get this list of MEMBERs in the library. Strip off the numeric suffix. Sort by the remaining text. Take the last (or first) one.
Let's test it. First let's make some datasets with those names.
data acct_cd_20210401 acct_cd_20210412 cof_fod_20200419 cof_fod_20220411 mrt_ftr_20200402 mrt_ftr_20220418;
set sashelp.class(obs=1);
run;
Now make the ordered list.
proc sql ;
create table list as
select catx('.',libname,memname) as dsname
, substr(memname,1,length(memname)-8) as basename
, scan(memname,-1,'_') as suffix
from dictionary.members
where libname='WORK'
and not missing(input(scan(memname,-1,'_'),?yymmdd8.))
order by 2,3
;
quit;
Now pick the last (latest) one for each basename and generate PROC CONTENT code.
data _null_;
set list;
by basename;
if last.basename;
call execute(catx(' ','proc contents data=',dsname,';run;'));
run;
... View more