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
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.
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.
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.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9.
Lock in the best rate now before the price increases on April 1.
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.
Ready to level-up your skills? Choose your own adventure.