See this macro code:
libname XYZ "/unix/mypath/project/202012";
%macro wait_till_ready;
%local today modate x;
%let today = %sysfunc(today());
proc sql noprint;
select datepart(modate) into :modate
from dictionary.tables
where libname = "XYZ" and memname = "PROJECT_DATASET"
;
quit;
%if &sqlobs = 0
%then %do;
%put "Dataset does not exist!";
%abort cancel;
%end;
%do %while (&modate ne &today);
%let x = %sysfunc(sleep(60,1)); /* wait a minute */
proc sql noprint;
select datepart(modate) into :modate
from dictionary.tables
where libname = "XYZ" and memname = "PROJECT_DATASET"
;
quit;
%if %sysfunc(today()) gt &today
%then %do;
%put "No new data for this day!";
%abort cancel;
%end;
%end;
%mend;
The macro will check first if the dataset exists; if not, a message is issued and an error condition raised, and in a non-interactive session (batch), the session is terminated.
It retrieves the modification timestamp from DICTIONARY.TABLES, extracts the date, and compares that to the rundate of the job. If the dates don't match, it waits for a minute,
If the current date exceeds the rundate, a message is issued and the job/submit terminated abnormally.
... View more