Suppose I have some data sets in library lib
, their names look like Table_YYYYMMDD
(e.g. Table_20150101
).
I want to get a name of a data set with maximum date (YYYYMMDD) and store it in a macro variable.
I'm using proc sql
and from dictionary.tables
.
First I extract a YYYYMMDD
part of name. Then I should convert it to date and then find MAX. And I want to be sure that I have at least one data set in library.
proc sql;
select put(MAX(input(scan(memname, 2, '_'), yymmdd8.)), yymmddn8.)
into :mvTable_MaxDate
from dictionary.tables
where libname = 'LIB';
quit;
So,
Is it right to use sas functions like
scan
inproc sql
?How could I check whether the query is not empty (mvTable_MaxDate hasn't missing value)?
Thanks for your help:)