Wednesday, March 4, 2015

run time analysis (with -TERMSTMT)

Some batches may take long time. You definitely do not want to wait until it finish. So when you kick off the batch, you can add the system option -TERMSTMT to run the program at below. For the tip -TERMSTMT, please see my previous post.
filename a temp;
filename mymail email "mail@address" subject="The job finished. Please check!";
options nonotes;
data _null_;
    file a;

    start_dttm = "&sysdate9 &systime"dt;
    end_dttm = datetime();
    run_time = end_dttm - start_dttm;

    run_minutes = intck('minute', start_dttm, end_dttm);
    if run_minutes > 15 then do;
        put "data _null_;";
        put "file mymail;";
        put "put 'Run time analysis:';";
        put "put '" "start time: " start_dttm datetime. "';";
        put "put '" "end time: " end_dttm datetime. "';";
        put "put '" "Run time: " run_time time5. "';";
        put "put '" "*** Run minutes ***: " run_minutes "';";
        put "run;";
    end;
run;

%inc a;

No comments: