Capturing NOTE generated by _ERROR_ condition from input statement

Viewed 67

Below is a simple representation of my problem. I do not control the data, nor the format applied (this is a backend service for a Stored Process Web App). My goal is to return the error message generated - which in this case is actually a NOTE.

data _null_;
input x 8.;
cards;
4 4
;
run;

The above generates:

NOTE: Invalid data for x in line 61 1-8. RULE:
----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0 61 4 4 x=. ERROR=1 N=1 NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds

It's easy enough to capture the error status (if _error_ ne 0 then do) but what I'd like to do is return the value of the NOTE - which handily tells us which column was invalid, along with line and column numbers.

Is this possible without log scanning? I've tried sysmsg() and syswarningtext to no avail.

1 Answers

AFAIK, There is no feature for capturing the NOTES a data step causes while the data step is running.

Since you are in STP environment, you might either use either:

  • -altlog at session startup or
  • proc printto log=… wrap of the step

and do that scan.

Related