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.
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.
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
Syntax
TERMSTMT=’statement(s)’
Syntax Description
’statement(s)’
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.
Details
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.
Comparisons
TERMSTMT= specifies the SAS statements to be executed at SAS termination, and
INITSTMT= specifies the SAS statements to be executed at SAS initialization.
Ksharp
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.
Here's a warped approach. Redefine your macro as
%macro Run;
run;
<code from your ERR macro here>
%mend;
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.
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.
Maybe this would help you cancel further statements in case of errors David:
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.
Hi..Hellind
Did you find any solution for this.? Am searching for same kind of solution..
Thanks,
Kishore Vengala
You can do that with SAS Enterprise Guide. See: Tool>Options>SAS Programs.
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 25. 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.