Tracking progress in SAS programs in SAS Enterprise Guide

7

You might be the sort of person who loves to wait indefinitely. You visit the DMV regularly to tweak your auto registration. You queue up in the supermarket checkout line behind the customer most likely to require "price checks". You map your daily commute along the routes that offer the least certainty for traffic volume and faulty signals.

But most of us, even as we say we enjoy "living in the moment", like to have some idea about when our current activity will end and we'll be free to move on to the next activity. It's that sense of progress that keeps us going, especially during the work day.

When you run a big long SAS program in SAS Enterprise Guide, and you open the task status window to see how it's going, do you like to see the status as "Running...", whether it's been running for 10 seconds or 10 minutes or an hour? Or would you rather see something more meaningful, such as "10 out 12 steps complete - almost done..."?

A better, more useful status

If you answered the latter, then you will enjoy the new feature in SAS 9.2 and SAS Enterprise Guide 4.2 that allows you to instrument your SAS programs to report the current progress within the task status window. This trick is made possible by a new SAS global statement, SYSECHO.

The remainder of this post provides instructions and a code example for using the SYSECHO statement. (5 more short paragraphs plus a code block, for those keeping track of blog post status.) You can sprinkle the SYSECHO statement throughout your programs to add more insight into your task status window. However, even though you can use the SYSECHO statement anywhere (it is a global statement), it's most effective if you place it just inside the DATA step or PROC step block.

SAS Enterprise Guide already provides status updates when your program is processing; it reports a status change each time a new step boundary (such as a DATA or PROC step) begins. To preserve a useful SYSECHO status, you need to place the statements after a DATA step or PROC statement. Otherwise, your informative SYSECHO text will be overridden by the more generic "step boundary encountered" status.

When used inside a DATA step, only the last SYSECHO statement will be reflected in the status window. Why? Because SAS global statements are processed at the time that a DATA step is compiled, not as it's being run. So even though your DATA step statements might seem to take a while to run, the SYSECHO statements are not processed in serial within the step -- they are processed all at once, in the beginning.

However, for certain interactive SAS procedures such as PROC SQL, you can use multiple SYSECHO statements to show more status information between statements.

This example program shows a SAS program that has been adorned with SYSECHO statements designed to communicate status information. The program is somewhat contrived, including some SLEEP function calls to simulate longer operations. You can paste this into your SAS Enterprise Guide 4.2 session and see how it works. Be sure to select View->Task Status to make the task status window visible.

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

About Author

Chris Hemedinger

Senior Manager, SAS Online Communities

+Chris Hemedinger is the manager of SAS Online Communities. Since 1993, Chris has worked for SAS as an author, a software developer, an R&D manager and a consultant. Inexplicably, Chris is still coasting on the limited fame he earned as an author of SAS For Dummies.  He also hosts the SAS Tech Talk webcasts each year from SAS Global Forum, connecting viewers with smart people from SAS R&D and the impressive work that they do.

Related Posts

7 Comments

  1. Hello Chris,

    It is necessary to add that SYSECHO should be inserted into LONG executed data step or procedure otherwise it will be overritten by regular status. I think that for user friendly solution it would be good to maitain a list of consecutive statuses in STATUS window for user defined statuses.

    Sincerely,
    Alexander

    • I agree; a way to keep track of the SYSECHO statements that have been issued would be a good thing.

      I think I'd prefer that they be written to the project log.

      • Chris Hemedinger
        Chris Hemedinger on

        Thanks Jack. Per what you saw at WUSS, I'll also be writing a follow-up post about how DOSUBL can make DATA step tracking (and crude debugging) possible within EG.

  2. Pingback: Implement BY processing for your entire SAS program - The SAS Dummy

  3. Pingback: How much time will your process flow take to run? - The SAS Dummy

  4. Andrew Howell on

    Love the sysecho statement! Particularly when you are running a large piece of code that takes a long time. I have a simply sysecho macro:

    %macro sysecho(msg);
    sysecho "&msg %sysfunc(datetime(),datetime19.)";
    %mend;

    and in my code use (for example): %sysecho(Extract from Oracle);

    That way I can keep track of which piece of code is executing, and how long it's taking..

  5. Pingback: Tracking progress in your program with SAS Enterprise Guide: another trick - The SAS Dummy

Leave A Reply

Back to Top