Chapter Contents

Previous

Next
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:

/* RCTEST SASMACRO - a SAS REXX macro */
/* Show SAS statements in the log */
'++SASLOG'                 
'data x;'
'do i = 1 to 10;'
'output;'
/* show rc in the SAS log */
'++SASLOG The RC value is:' rc
'run;'
/* show rc in the SAS log */
'++SASLOG The RC value is:' rc
exit

SAS Log for RCTEST shows the resulting SAS log.

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

  5    run;
         -
         117
  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

Previous

Next

Top of Page

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