Hi all SAS Users,
Normally, we can see how long does it take SAS EG and SAS Base to finish a code under this code in the LOG. But I am wondering how can we know the total time for SAS to run a set of code rather than manually calculating.
Warm regards.
I have EG run these macros automatically when I submit code.
%macro z_eg_pre_run;
%let syscc=0;
%global zegt;
%put %sysfunc(repeat(#,50));
%put# Run started: %sysfunc(datetime(),datetime20.);
%let zegt=%sysfunc(datetime());
%put %sysfunc(repeat(#,50));
%mend;
%macro z_eg_post_run;
%put %sysfunc(repeat(#,50));
%let zegt=%sysfunc(datetime())-&zegt;
%put# Elapse time: %sysfunc(hour(&zegt),z2.)h%sysfunc(minute(&zegt),z2.)m%sysfunc(second(&zegt),z2.)s;
%put %sysfunc(repeat(#,50));
%put# Run ended: %sysfunc(datetime(),datetime20.);
%put# &=syscc &=syserr;
%if &syscc>4 %then %put# SYSERRORTEXT = %superq(syserrortext);
%else %if &syscc>0 %then %put# SYSWARNINGTEXT = %superq(syswarningtext);
%put %sysfunc(repeat(#,50));
%mend;
In the EG options, add that at connection time, and insert the calls before/after submitted code.
I have EG run these macros automatically when I submit code.
%macro z_eg_pre_run;
%let syscc=0;
%global zegt;
%put %sysfunc(repeat(#,50));
%put# Run started: %sysfunc(datetime(),datetime20.);
%let zegt=%sysfunc(datetime());
%put %sysfunc(repeat(#,50));
%mend;
%macro z_eg_post_run;
%put %sysfunc(repeat(#,50));
%let zegt=%sysfunc(datetime())-&zegt;
%put# Elapse time: %sysfunc(hour(&zegt),z2.)h%sysfunc(minute(&zegt),z2.)m%sysfunc(second(&zegt),z2.)s;
%put %sysfunc(repeat(#,50));
%put# Run ended: %sysfunc(datetime(),datetime20.);
%put# &=syscc &=syserr;
%if &syscc>4 %then %put# SYSERRORTEXT = %superq(syserrortext);
%else %if &syscc>0 %then %put# SYSWARNINGTEXT = %superq(syswarningtext);
%put %sysfunc(repeat(#,50));
%mend;
In the EG options, add that at connection time, and insert the calls before/after submitted code.
Hi @ChrisNZ
It is exactly what I want. I am wondering that is there anything I need to concern about when using this code globally? I set it up as auto exec whenever I open SAS EG already.
Warm regards.
If you want to track the progress of your steps i.e. which one is being executed (and/or taking abnormally longer to run), use the SYSECHO global statement.
Sample code:
data class (drop=x);
sysecho "In the first DATA step";
set sashelp.class;
x = sleep(1);
run;
proc sql;
sysecho "Creating the first table, OUT";
create table out as
select name,
/* Calculation */
(sleep(1)) AS zzzz
from class where age>14;
sysecho "Creating the second table, OUT2";
create table out2 as
select name,
/* Calculation */
(sleep(1)) AS zzzz
from class where sex="M" and age>14;
quit;
%macro makedata(count);
%do i = 1 %to &count;
data outdata&i;
sysecho "Making data step &i of &count";
zzz = sleep(3);
run;
%end;
%mend;
%makedata(5);
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: