Wednesday, January 2, 2013

SAS: Continue processing despite errors

I have a SAS macro, used at the end of many programs, to update a submissions file indicating when a program has completed processing and the error code.  But this macro wouldn't work if the program failed.  And yet the log made it look like it was doing something there.  I was unaware of the NOSYNTAXCHECK option. I think the name is misleading.  What it really means is "don't just syntax check".

Here is a link to the SAS documentation:  http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#base-sysop-syntaxcheck.htm

"If a syntax or semantic error occurs in a DATA step after the SYNTAXCHECK option is set, then SAS enters syntax check mode, which remains in effect from the point where SAS encountered the error to the end of the code that was submitted. After SAS enters syntax mode, all subsequent DATA step statements and PROC step statements are validated. While in syntax check mode, only limited processing is performed."

So it was doing some "limited processing", just as the log seemed to indicate (such as resolving macro variables).

Another misleading entry on the log was that DATA steps were executed, but no output written.  I guess they were just syntax checked.

So I modified my macro as follows:

%macro updsub;
options nosyntaxcheck;  * processing regardless of previous errors ;
/* my macro code here */
options syntaxcheck;   * put it back as it (probably) was ;
%mend updsub;

Problem solved!

No comments:

Post a Comment