Chapter Contents


SAS Companion for the CMS Environment

Return Codes from SAS Statements Submitted by a SASMACRO

RC Variable

In a REXX program, the special variable RC is always set when any command string is submitted to an external environment. Ordinary execs submit CMS commands. When the CMS command completes and control is returned to REXX, the RC variable is set to the return code from the CMS command.

The RC variable is set in a slightly different way for a SASMACRO. The strings that are submitted to SAS are not necessarily complete execution units. SAS collects SAS language elements until it encounters a RUN statement, at which point it runs the SAS step. The RC variable is set to 0 when partial program fragments are submitted. The SAS return code is assigned to the REXX variable RC only for the string that contains the RUN statement.

RC Values

The value of the REXX RC variable is set to the value of the &SYSERR automatic SAS macro variable in all but four cases:

The following RCTEST SASMACRO demonstrates when the REXX variable RC gets set:

/* Show SAS statements in the log */
'data x;'
'do i = 1 to 10;'
/* show rc in the SAS log */
'++SASLOG The RC value is:' rc
/* show rc in the SAS log */
'++SASLOG The RC value is:' rc

SAS Log for RCTEST shows the resulting SAS log.

  1    rctest;
  ++++ data x;
  ++++ do i = 1 to 10;
  ++++ output;
  ++++ The RC value is:  0
  ++++ run;

  5    run;
  ERROR 117-185:  There were 1 unclosed DO blocks.

  NOTE:  The SAS System stopped processing this step because of errors.
  WARNING:  The data set WORK.X may be incomplete.  When this step was stopped,
            there were 0 observations and 1 variables.
  ++++   The RC value is: 1012

Chapter Contents



Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.