Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mp_abort.sas File Reference

abort gracefully according to context More...

Go to the source code of this file.

Detailed Description

Configures an abort mechanism according to site specific policies or the particulars of an environment. For instance, can stream custom results back to the client in an STP Web App context, or completely stop in the case of a batch run. For STP sessions

The method used varies according to the context. Important points:

  • should not use endsas or abort cancel in 9.4m3 WIN environments as this can cause hung multibridge sessions and result in a frozen STP server
  • The use of endsas in 9.4m6+ windows environments for POST requests to the STP server can result in an empty response body
  • should not use endsas in viya 3.5 as this destroys the session and cannot fetch results (although both mv_getjoblog.sas and the @sasjs/adapter will recognise this and fetch the log of the parent session instead)
  • STP environments must finish cleanly to avoid the log being sent to _webout. To assist with this, we also run stpsrvset('program error', 0) and set SYSCC=0. Where possible, we take a unique "soft abort" approach - we open a macro but don't close it! This works everywhere EXCEPT inside a %include inside a macro. For that, we recommend you use mp_include.sas to perform the include, and then call %mp_abort(mode=INCLUDE) from the source program (ie, OUTSIDE of the top-parent macro). The soft abort has become ineffective in 9.4m6 WINDOWS environments. We are currently investigating approaches to deal with this.
Parameters
[in]mac=(mp_abort.sas) To contain the name of the calling macro. Do not use &sysmacroname as this will always resolve to MP_ABORT.
[out]msg=message to be returned
[in]iftrue=(1=1) Condition under which the macro should be executed
[in]errds=(work.mp_abort_errds) There is no clean way to end a process within a include called within a macro. Furthermore, there is no way to test if a macro is called within a include. To handle this particular scenario, the include should be switched for the mp_include.sas macro. This provides an indicator that we are running a macro within a %include (_SYSINCLUDEFILEDEVICE) and allows us to provide a dataset with the abort values (msg, mac). We can then run an abort cancel FILE to stop the include running, and pass the dataset back to the calling program to run a regular %mp_abort(). The dataset will contain the following fields:
  • iftrue (1=1)
  • msg (the message)
  • mac (the mac param)
[in]mode=(REGULAR) If mode=INCLUDE then the &errds dataset is checked for an abort status. Valid values:
  • REGULAR (default)
  • INCLUDE
Version
9.4
Author
Allan Bowe

Related Macros

Definition in file mp_abort.sas.