BookmarkSubscribeRSS Feed
hellind
Quartz | Level 8

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.

9 REPLIES 9
Tom
Super User Tom
Super User

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.

Ksharp
Super User

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

hellind
Quartz | Level 8

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.

ballardw
Super User

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.

CBADavid
Calcite | Level 5

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.

ChrisNZ
Tourmaline | Level 20

Maybe this would help you cancel further statements in case of errors David:

http://support.sas.com/kb/24/825.html

hellind
Quartz | Level 8

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.

http://www.nesug.org/proceedings/nesug05/ap/ap9.pdf

kishore415
Calcite | Level 5

Hi..Hellind

Did you find any solution for this.? Am searching for same kind of solution..

Thanks,

Kishore Vengala

data_null__
Jade | Level 19

You can do that with SAS Enterprise Guide.  See: Tool>Options>SAS Programs.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 9 replies
  • 2772 views
  • 0 likes
  • 8 in conversation