BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Phil_NZ
Barite | Level 11

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.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

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. 

 

View solution in original post

4 REPLIES 4
ChrisNZ
Tourmaline | Level 20

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. 

 

Phil_NZ
Barite | Level 11

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.

Thank you for your help, have a fabulous and productive day! I am a novice today, but someday when I accumulate enough knowledge, I can help others in my capacity.
qoit
Pyrite | Level 9

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.

 

Link: https://blogs.sas.com/content/sasdummy/2009/05/26/tracking-progress-in-sas-programs-in-sas-enterpris...

 

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);

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 574 views
  • 5 likes
  • 3 in conversation