Chapter Contents |
Previous |
Next |
SAS Component Language: Reference |
The value of a SAS system return code can be interpreted as:
0 | The operation was completed successfully. |
>0 | An error condition was detected during the operation. |
<0 | The operation was completed, but a warning or a note was generated. |
Not all SCL functions that return completion code values return SAS system return codes. Some functions return a completion code value that reports the success or failure of the requested operation (usually 1 for success or 0 for failure). These values are referred to in this book simply as return codes because they do not have the special property of SAS system return codes described above.
Obtaining a SAS System Return Code |
The following example assigns the SAS system return code to the variable ERRNUM if the OPEN operation fails:
tableid=open('prices','I'); if tableid=0 then do; errnum=sysrc(); put "Open failed" errnum; end;
Note: If you call the SYSRC function after
executing a function that returns a SAS system return code, the value that
the SYSRC function returns is the same as the value that the original function
returned.
Obtaining the Message for a SAS System Return Code |
You can use the SYSMSG function to return the text of the error message that was produced by the most recent SCL warning or error.
For example, the following statements display the SAS system message for the error condition that is produced when the FETCH function returns a nonzero return code:
rc=fetch(dsid); if rc then _msg_=sysmsg();
The message string that SYSMSG() returns is reset to blank after each call to SYSMSG() until the next error or warning condition occurs.
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.