/************************************************************* *H* PROGRAM: m_get_datadate.sas *H* *H* USAGE: Get the date of the dataset *H* *H* REQUIRES: *H* *H* PRODUCES: &dtvar, &&tmvar, dttmvar *H* *H* REVISION HISTORY: *H* *H* *H* *************************************************************/ %macro m_get_datadate(lib=draw, dsn=dm, dtvar=datadate, tmvar=datatime, dttmvar=datadttm); %global &dtvar &tmvar &dttmvar; /* proc sql noprint; select put(datepart(crdate), yymmdd10.), put(timepart(crdate), time.) into :&dtvar., :&tmvar. from sashelp.vtable where libname=upcase("&lib.") and memname=upcase("&dsn.") ; quit; */ data _null_; /* Allocate file */ dsnpath=pathname("&lib")||"\&dsn..sas7bdat"; rc=FILENAME('myfile', dsnpath); /* Open file */ fid=FOPEN('myfile'); /* Retrieve last modified date */ moddate=input(finfo(fid,"Last Modified"),datetime.); call symput('_dtvar', put(datepart(moddate), yymmdd10.)); call symput('_tmvar', put(timepart(moddate), tod8.)); /* Close the file */ rc=FCLOSE(fid); /* Deallocate the file */ rc=FILENAME('myfile'); run; %let &dtvar=&_dtvar; %let &tmvar=&_tmvar; %let &dttmvar=&_dtvar.T&_tmvar.; %put Lib=&lib Dataset=&dsn, &dtvar=%sysfunc(strip(&_dtvar.)), &tmvar=%sysfunc(strip(&_tmvar.)) and &dttmvar=&&&dttmvar..; %mend m_get_datadate;