> 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.
> Bob Fitzgerald
There are several ways to approach this ideal but no simple way to
approach it without a lot of up-front programming.
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
...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( myvar );
when( 1, 2, 3 ); /* null statement, value ok */
error "ERROR: (pgmr) invalid value for MYVAR: " myvar=;
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
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
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
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 (firstname.lastname@example.org)
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
9:52am up 17 days, 10:59, 5 users, load average: 1.15, 1.19, 1.18