Production Ready Macros for SAS Application Developers 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 environments as this can cause hung multibridge sessions and result in a frozen STP server
  • should not use endsas in viya 3.5 as this destroys the session and cannot fetch results (although both 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. 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 to perform the include, and then call %mp_abort(mode=INCLUDE) from the source program (ie, OUTSIDE of the top-parent macro).
mac=to contain the name of the calling macro
msg=message to be returned
iftrue=supply a condition under which the macro should be executed.
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 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)
mode=(REGULAR) If mode=INCLUDE then the &errds dataset is checked for an abort status. Valid values:
  • REGULAR (default)

Related Macros

Allan Bowe

Definition in file