Previous Page | Next Page

SAS System Return Codes

Testing for a Particular Error or Warning Condition

When an SCL function returns a nonzero SAS system return code, you can use the %SYSRC macro to determine whether the code indicates one of a defined set of error and warning conditions. The %SYSRC macro is provided in the autocall library that is supplied by SAS Institute.

Note:   In order for you to use autocall macros, the MAUTOSOURCE system option must be in effect, and the SASAUTOS= system option must point to the Institute-supplied autocall macro library. For more information about the autocall facility, see SAS Macro Language: Reference and the online Help for the SAS Macro Language.  [cautionend]

To test whether a specific return code is one of the documented conditions, pass a mnemonic name for the condition to the %SYSRC macro. The syntax is

rc=%SYSRC(mnemonic);

Mnemonics consist of up to eight characters, as follows:

For example, _SWEOF is the mnemonic for the end-of-file warning condition.

Note:   The return code for an end-of-file condition is a warning (_SWEOF). The value of the return code is -1.   [cautionend]

Mnemonics are assigned only to error or warning conditions that are considered relevant to an application developer. In some cases, SCL returns values that do not have a corresponding mnemonic. In these cases, a negative value indicates a warning condition, and a positive value indicates an error condition. For example, the following statements can be used to test whether the row requested by the FETCH function was successfully locked:

rc=fetch(dsid);
if (rc) then
   do;
      if (rc=%sysrc(_swnoupd)) then _msg_=
     'Another user has locked the requested row.';
      else
             /* fetch failed for another reason*/
         _msg_=sysmsg();
   end;

Previous Page | Next Page | Top of Page