LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (June 1999, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:   Fri, 11 Jun 1999 17:19:43 +0000
Reply-To:   kmself@ix.netcom.com
Sender:   "SAS(r) Discussion" <SAS-L@UGA.CC.UGA.EDU>
From:   "Karsten M. Self" <kmself@IX.NETCOM.COM>
Organization:   Self Analysis
Subject:   Re: Stop Processing on Any Problem
Comments:   To: Bob Fitz <PW098@AOL.COM>, sas-l <sas-l@listserv.uga.edu>
Content-Type:   text/plain; charset=us-ascii

> Date: Fri, 11 Jun 1999 03:43:41 EDT > From: Bob Fitz <PW098@AOL.COM> > Subject: Stop Processing on Any Problem > > Hi SAS-Ler's, > > I want to put a job in production and I want it to stop processing on even > the smallest of problems. For example, if I dynamically allocate a SAS > library but it doesn't exist, SAS prints a message but continues to process. > I have got around this with the fileexist test before allocating but I still > want to know how to make it abend. The same holds true if a variable that I > preform a SAS date function has an invalid value. I get a warning but SAS > continues to process. I tried the system option ERRORABEND but it is not > doing what I expected. > > TIA, > Bob Fitzgerald

There are several ways to approach this ideal but no simple way to approach it without a lot of up-front programming.

ABORT ABEND;

In a datastep will terminate the step with an error. It can be coupled with conditional processing logic to vet variable values and/or other conditions.

OPTIONS ERRORABEND;

...will cause your SAS process to terminate on any error condition. This may be desirable in batch processing but can be frustrating if you are doing interactive (Display Manager) processing. There is no simple way to conditionally terminate interactive processing without terminating the entire SAS session.

A number of error level options settings are available, including FMTERR, DKRICOND, DKROCOND, and others. I generally set strong error checking for my SAS sessions as a matter of course, and set these options in my config.sas file.

If your program is written as a macro, you can conditionally test and terminate processing by referencing an automatic macrovariable, memory fails me but I believe it's &SYSERR. This is set after many, but not all, SAS procedures, if errors are encountered in processing.

In a data step, there is no way to specify automatically a range of valid or invalid data values. It is possible to approach this with conditional processing, either IF/THEN/ELSE or, preferably, SELECT/WHEN/OTHERWISE:

select( myvar ); when( 1, 2, 3 ); /* null statement, value ok */ otherwise do; error "ERROR: (pgmr) invalid value for MYVAR: " myvar=; abort abend; end; end; /* select myvar */

...unfortunately, it's not possible to specify value ranges in a WHEN statement, or to specify more complex test conditions on a non-null SELECT statement, though a null SELECT statement allows certain more complex logical expressions at a loss of clarity of what is being tested:

select(); when( 1 le myvar le 5 or 11 le myvar le 15 ); /* null */ otherwise do; /* error processing */; end; end; /* select */

The '?' and '??' modifiers can be used in a PUT or INPUT statement to test success of value assignment, for example, data values. This is documented in "SAS Language, Reference, Version 6, 2nd Edition" under PUT and INPUT. Briefly, the '?' operator produces an error message, the '??' operator sets the _ERROR_ variable but suppresses the error message:

if _error_ then abort abend; put( myvalue, ?? mmddyy10. ); if _error_ then do; /* input error condition */; end;

For explicitly testing existence of external files and libnames, SCL functions can be used in either macro or data step to test existence or successful assignment of librefs and filerefs.

Unfortunately, in the aim of making an easy to use system, SAS tends to give the user the benefit of the doubt in many situations, without providing straightforward means to disable this behavior when strictly correct processing is required.

-- Karsten M. Self (kmself@ix.netcom.com) What part of "Gestalt" don't you understand?

SAS for Linux: http://www.netcom.com/~kmself/SAS/SAS4Linux.html Mailing list: "subscribe sas-linux" to mailto:majordomo@cranfield.ac.uk 9:52am up 17 days, 10:59, 5 users, load average: 1.15, 1.19, 1.18


Back to: Top of message | Previous page | Main SAS-L page