Help using Base SAS procedures

Error handling in a SAS web application

Accepted Solution Solved
Reply
Regular Contributor
Posts: 194
Accepted Solution

Error handling in a SAS web application

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


Accepted Solutions
Solution
‎10-23-2015 09:47 AM
Regular Contributor
Posts: 194

Re: Error handling in a SAS web application

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


All Replies
Regular Contributor
Posts: 194

Re: Error handling in a SAS web application

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.

Solution
‎10-23-2015 09:47 AM
Regular Contributor
Posts: 194

Re: Error handling in a SAS web application

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.

Occasional Contributor
Posts: 15

Re: Error handling in a SAS web application / grabbing SAS-Log in any case

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.

Regular Contributor
Posts: 194

Re: Error handling in a SAS web application

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)
Occasional Contributor
Posts: 15

Re: Error handling in a SAS web application

thank you for the hint with the _debug=log.
That's pretty easy (I'm new to SAS...Smiley Happy )
☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 402 views
  • 1 like
  • 2 in conversation