Generating Descriptive Please Wait Messages for Long Running Stored Processes

From sasCommunity
Jump to: navigation, search

DRAFT - NOT YET COMPLETE!

Contents

Overview

The complete source code for the pleaseWait macro and the sample call as discussed on the blog entry

on Jurassic SASĀ© in the BI/EBI World

The pleaseWait macro source

%macro pleaseWait
      (message=Please Wait,    /* default message */
       close=                  /* if non-blank, just close the previous div tag */
      );
 
 /*------------------------------------------------------------------------------------------
   Copyright (c) 2010 Henderson Consulting Services
                 This macro can be freely copied/used/distributed as long as the original
                 source/developer is acknowledged (e.g., a link to this article).
   PROGRAMMER   : Don Henderson
   PURPOSE      : Generates a please wait message.
 
                  Used to generate please wait messages. Uses DIV tags to display/hide the
                  messages.
 
                  Can be called repeatedly to provide updated messages. Each call will 
                  hide any previous please wait messages before displaying the next one.
 
                  Once the final output is ready to be dispalyed, this macro should be
                  called with a non-blank value for the close parameter to hide the previous
                  message.                  
 
 |------------------------------------------------------------------------------------------|
 |  MAINTENANCE HISTORY                                                                     |
 |------------------------------------------------------------------------------------------|
 |  DATE    |     BY    | DESCRIPTION                                                       |
 |----------|-----------|-------------------------------------------------------------------|  
 | Mar 2010 |  Don H    | Original creation
 |-----------------------------------------------------------------------------------------*/
 
 %global pleaseWaitCounter;
 
 %if &pleaseWaitCounter ne %then /* close/hide prior please wait wait message */
     %str(ods html text = "<script>pleaseWait&pleaseWaitCounter..style.display = ""none""</script>";);
 
 %if %length(&close) = 0 %then
 %do;  /* not simply closing the prior please wait */
 
    %let pleaseWaitCounter = %eval(&pleaseWaitCounter+1);
 
    data pleasewait;
     /* create a data set with the image - using an image provided by the SAS install */
     msg = '<img src="/SASStoredProcess/images/progress.gif">';
    run;
 
    ods html text = "<span id=""pleaseWait&pleaseWaitCounter"">";
    proc report data = pleaseWait nowd;
     title "&message";
     columns msg;
     define msg / " ";
    run;
    ods html text = '</span>';
 
 %end; /* not simply closing the prior please wait */
 
%mend pleaseWait;

The sample macro used in the blog entry

%macro pleaseWaitExample;
 
 %pleaseWait(Message=Please Wait - Starting Execution)
 
 %do i = 1 %to 4;
 
    /* For purposes of illustration, just goes to sleep for 5 seconds.
       Including this in a macro loop illustrates providing an updated
       status message
    */
    data _null_;
     /* simulate a longer process */
     x = sleep(5);
    run;
 
    %pleaseWait(Message=Step &i of 4 Completed)
 
 %end;
 
 %pleaseWait(close=y) /* hides the previous message without generating a new one */
 
 proc print data = sashelp.class(obs=5);
  title "Please Wait Example";
  footnote ;
 run;
 
%mend pleaseWaitExample;
Personal tools
Namespaces
Variants
Actions
Navigate
Sasopedia Detail
Contribute
Connect
Toolbox