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

Hi all,

 

I work on a SAS web application. Whenever an error occur, the user is faced

with a "Stored process error" message and a button to toggle log display.

I would like instead to display a custom web page indicating which information

to provide to the support team.

I tried the following code without success.

 

%macro error_handling;

    data foo;
       Something goes wrong !!!!
    run;

    %if &syscc. %then %do;
        %let syscc=0;

        data _NULL_;
            file _webout;
            put "<html><body><h1>Huho ! Something went wrong</h1></body></html>";
        run;

    %end;
    %else %do;
        data _NULL_;
            file _webout;
            put "<html><body><h1>Hello</h1></body></html>";
        run;
    %end;

%mend;

%error_handling;

 

Thanks for your help

1 ACCEPTED SOLUTION

Accepted Solutions
gamotte
Rhodochrosite | Level 12

I managed to suppress the error message and LOG button by resetting syscc before the data step that generates the web page.

So my problem is solved.

View solution in original post

5 REPLIES 5
gamotte
Rhodochrosite | Level 12

Found this :

 

http://support.sas.com/kb/16/225.html

 

I tried the given macro :

 

   /* 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 "<h3>Sorry, your request was not processed successfully.<h3>";
     rc = stpsrvset('program error', 0);
     run;
    %end;

  %let syscc=0;

 %mend checkcc;


 %checkcc;

It improves upon my previous program as the custom page is displayed but the "Show log button" is still there.

gamotte
Rhodochrosite | Level 12

I managed to suppress the error message and LOG button by resetting syscc before the data step that generates the web page.

So my problem is solved.

defaz
Fluorite | Level 6

I know this is an old thread, but perhaps somebody is looking for an alternative solution:

 

At the start of the web page body I create a hidden div 'debug_content' for debugging content, and a dokument.ready() function:

(here: jquery and jquery-ui is used, but also working with pure javascript)

 

<script type="text/javascript">	
$(document).ready(function() {  
/* if SASLog exists then add it to debug menu*/
  if (document.getElementById("SASLog")) {
    $( '#menu10' ).append( "<li id='li0'><a href='#dbg0' id='dbg0_link' rel='dbg0' class='dbglink nav'>SAS Log</a></li>" );
/*debug_content is a hidden div to hold debugging stuff - now add a new div for SAS log*/
    $('#debug_content').append("<div id='dbg0' class='debug' title='SAS Log'></div>");
    $('#dbg0').hide();                 /* hide the newly created div */
    $('#SASLogbutton').hide();         /* hide the SASLog button */
    $('#dbg0').append($('#SASLog'));   /* MOVE the SASLog to the newly created div */
    $('#SASLog').show();               /* SASLog is hidden by default - show it in the hidden div*/
    $('#dbg0_link').click(function(){  /* show dialog when the menu entry is clicked */
      var id = $(this).attr('rel');
      $('#'+id).dialog({
       maxWidth:1600,
       width: 1200,
       position: { my: 'top', at: 'top' },
       closeOnEscape: true,
       height: 500,
       maxHeigth:900
       });
      $(window).scrollTop(0);
    });
  }
});
</script>

 

So when the page is entirely built, it checks for the SASLog-Id, creates a new div in the 'debugging_content'  an moves the entire SASLog in that div. The log button is hidden and a new menu entry for the SAS-log is created. The user just see the STP error  message.   

I use this technic not only for SAS-log but also for e.g. list of macro variables, displaying work tables and so on.

 

 

Perhaps someone finds this useful.

 

 

p.s. I'm looking for a way to catch the SASlog if NO error occurs.

gamotte
Rhodochrosite | Level 12
Thanks for your comment. Regarding your question, the stored process has to be called with the parameter _debug valued to 'log'. You can for instance add a hidden input field _debug on the calling web page (post) or add the parameter/value in the URL (get)
defaz
Fluorite | Level 6
thank you for the hint with the _debug=log.
That's pretty easy (I'm new to SAS...:) )

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 5 replies
  • 1653 views
  • 1 like
  • 2 in conversation