BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PhilMason
Obsidian | Level 7

I have a complex application that uses SAS stored processes called using Ajax. If the stored process works properly then we will stream a JSON message to the browser which we can pick up and determine whether the function of the stored process was a success or failure, as well as other information included in the JSON message. However if the stored process has an error, then we get a bunch of HTML streamed back along with the "show SAS log" button etc. I would like to override what the stored process web application is doing here and I would rather it just returned a JSON message saying that it had failed or something similar. Is there a way to override this? I'd appreciate any ideas/suggestions/answers. thanks, Phil Mason

p.s. We are using SAS 9.1.3 SP4 with Tomcat on a Windows server.

1 ACCEPTED SOLUTION

Accepted Solutions
PhilMason
Obsidian | Level 7

Below is some code that shows how to solve this, thanks to Dimitri Woei.

%stpbegin ;

* this works ;
proc print data=sashelp.class ;
run ;
%put syserr=&syserr;

* this fails ;
proc errorintheprocname data=sashelp.class ;
run ;
%put syserr=&syserr;

* this wont run since there was an error ;
data _null_;
  a=1;
run;
%put syserr=&syserr;

* this also wont run ;
proc print data=sashelp.class ;
run;
%put syserr=&syserr;

%stpend ;

/* Add the below code at the bottom of your stored process. */
/* If an error occurs, then your customized error message   */
/* will be displayed in the HTML output.                    */
/* The "Show SAS log" button will not be displayed.         */

%macro checkcc;
options obs=max no$syntaxcheck;
%if (&syscc gt 4) %then %do;
data _null_;
  file _webout;
  put "<p><h3>Sorry, your request was not processed successfully.<h3>";
  rc = stpsrvset('program error', 0);
run;
%end;

%let syscc=0;
%mend checkcc;

%*** To see the difference try running this with the following line commented out, and then uncommented ;
%checkcc;

View solution in original post

3 REPLIES 3
NN
Quartz | Level 8 NN
Quartz | Level 8

Hi,

Not sure if i can be of much help here...

We used to create our own error messages for our stored processes in sas 9.1.on Unix environment.

To hide the log we used the Debug mask by creating a hidden prompt and setting the value _debug = 0

Then i think the stperror macro gave the information if there was an error in the processes and based on the return codes that sas generated we used to customise the output that was shown to the user.

Will this be of any help...

PhilMason
Obsidian | Level 7

Below is some code that shows how to solve this, thanks to Dimitri Woei.

%stpbegin ;

* this works ;
proc print data=sashelp.class ;
run ;
%put syserr=&syserr;

* this fails ;
proc errorintheprocname data=sashelp.class ;
run ;
%put syserr=&syserr;

* this wont run since there was an error ;
data _null_;
  a=1;
run;
%put syserr=&syserr;

* this also wont run ;
proc print data=sashelp.class ;
run;
%put syserr=&syserr;

%stpend ;

/* Add the below code at the bottom of your stored process. */
/* If an error occurs, then your customized error message   */
/* will be displayed in the HTML output.                    */
/* The "Show SAS log" button will not be displayed.         */

%macro checkcc;
options obs=max no$syntaxcheck;
%if (&syscc gt 4) %then %do;
data _null_;
  file _webout;
  put "<p><h3>Sorry, your request was not processed successfully.<h3>";
  rc = stpsrvset('program error', 0);
run;
%end;

%let syscc=0;
%mend checkcc;

%*** To see the difference try running this with the following line commented out, and then uncommented ;
%checkcc;

NN
Quartz | Level 8 NN
Quartz | Level 8

This is great.... Had been looking for something like this..Smiley Happy

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2083 views
  • 0 likes
  • 2 in conversation