I have a series of stored processes that perform tasks are are called from a Web application via the Stored Process Web App. I have error checking in the code and want to return a JSON string with error messages instead of the whole SAS log. My web developers don't need to see the SAS log or to have to parse it. They just need some basic information. Found this which puts me on the right track, but it doesn't seem to work with PROC JSON. My macro is as follows: %macro status_output(_webout);
%let syserr=0;
%let syscc=0;
proc json out=&_webout pretty nosastags;
write values "STATUS" "&rc";
%if %sysevalf(&rc > 0) %then %do;
write values "ERROR";
write open object;
write values "ERROR_MSG" "&ERROR_MSG";
write values "ERROR_REASON" "&ERROR_REASON";
write close;
%end;
run;
%mend; However, when an error occurs, I still get the SAS Log and not my nice error handling. I do see this in the log: 7435 +%status_output(_webout);
MPRINT(STATUS_OUTPUT): proc json out=_webout pretty nosastags;
MPRINT(STATUS_OUTPUT): write values "STATUS" "1008";
MPRINT(STATUS_OUTPUT): write values "ERROR";
MPRINT(STATUS_OUTPUT): write open object;
MPRINT(STATUS_OUTPUT): write values "ERROR_MSG" "In insert_variable - RC:1008";
MPRINT(STATUS_OUTPUT): write values "ERROR_REASON" "Error Adding Variable - ORACLE: ORA-00001: unique constraint (IF_A2RPT.FACTOR_VARIABLES_UK1) violated;
MPRINT(STATUS_OUTPUT): write close;
MPRINT(STATUS_OUTPUT): run;
WARNING: RUN statement ignored due to previous errors. Submit QUIT; to terminate the procedure.NOTE: PROCEDURE JSON used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds There is no ERROR in PROC JSON, which leads me to believe it might be checking another system macro variable. Curiously, if I execute the code from SAS Studio (writing to a different file than _webout), this run without problem and the file is populated beautifully. This leads me to also believe there is something I can set to override the annoying behavior. Anyone know what I need to do?
... View more