05-23-2012 10:25 PM
I have a macro %ERR that checks for error and play a sound. I want this macro to run it every time when I execute a code. Instead of manually running %ERR, is there anywhere to setup in Preferences so that it automatically runs?
There is a similar feature in Tools > Options > Preferences > Results for HTML Output which is very useful.
05-23-2012 11:23 PM
Not sure what you mean. Are you running programs interactively from the SAS Display Manager? Then you can issue any commands you want and even define keys to execute the commands for you. You can even add icons to run the commands. For example you could define the F8 key to be the command sequence submit followed by the gsub command to submit the call to your %ERR macro. You can also define command macros that instead of generating SAS program statements can be used to generate Display Manager commands like submit or gsub.
05-23-2012 11:44 PM
Yes. SAS offer a system option to solve such problem. You can populate the statements of the macro into this option . and these statements will execute after the code running.
TERMSTMT= System Option
Specifies the SAS statements to execute when SAS terminates.
Valid in: configuration file, SAS invocation
Category: Environment control: Initialization and operation
PROC OPTIONS GROUP= EXECMODES
is one or more SAS statements.
Maximum length: 2,048 characters
Operating Environment Information: In some operating system environments there is
a limit to the size of the value for TERMSTMT=. To circumvent this limitation, you can
use the %INCLUDE statement.
TERMSTMT= is fully supported in batch mode. In interactive modes, TERMSTMT= is
executed only when you submit the ENDSAS statement from an editor window to
terminate the SAS session. Terminating SAS by any other means in interactive mode
results in TERMSTMT= not being executed.
An alternate method for specifying TERMSTMT= is to put a %INCLUDE statement
at the end of a batch file or to submit a %INCLUDE statement before terminating the
SAS session in interactive mode.
TERMSTMT= specifies the SAS statements to be executed at SAS termination, and
INITSTMT= specifies the SAS statements to be executed at SAS initialization.
05-25-2012 02:15 AM
TERMSTMT= is fully supported in batch mode. In interactive modes, TERMSTMT= is executed only when you submit the ENDSAS statement from an editor window to terminate the SAS session. Terminating SAS by any other means in interactive mode results in TERMSTMT= not being executed.
I am using SAS Display Manager. I want it to play a loud sound when it hits a error. TERMSTMT can be used in SAS invocation which is good. But it seems it only executes when SAS terminates. (ENDSAS will close SAS session which I do not want)
I am exploring all the solutions suggested in this thread. Thanks.
05-24-2012 10:19 AM
Here's a warped approach. Redefine your macro as
<code from your ERR macro here>
Then any proc or data step you want end with %run; instead of a simple run; statement.
If the issue is getting tired of typing the macro into the code then create an editor macro to insert the statement.
Tom's approach is probably better though.
05-24-2012 06:16 PM
I would like to see your error checking code if you're prepared to share? I've long been trying to write something which determines whether an error occurs and can decide whether to submit further statements or not.
05-24-2012 07:26 PM
05-25-2012 02:19 AM
I am still exploring. I am not running a batch jobs. I am using SAS Display Manager interactive. Sometimes, I am tired to trying to read the long logs, I want it to play a loud sound.
Error Checking Macro will be based on this paper, but instead of emailing me, it will play a sound.