Chapter Contents


SAS Companion for the CMS Environment

Mode Switching

In addition to submitting SAS language statements from a SASMACRO, you can use a SASMACRO to temporarily pass interactive control to the SAS session. This environment, called SAS SUBSET, is similar in concept to CMS SUBSET. A SASMACRO (or any REXX program that is executed while a SASMACRO is running that has ADDRESS SAS in effect), can pass control to SAS SUBSET by issuing the following directive:


To exit SAS SUBSET and return to the suspended exec, submit the following SAS statement:


CMSRETURN is accepted as a valid SAS statement only when SAS SUBSET is in effect, and it cannot be submitted from a SASMACRO.

The following example demonstrates switching from a SAS session to an XEDIT session to SAS SUBSET and back again by using a SASMACRO and an XEDIT macro.

The program named SASXEDIT SASMACRO shows how to temporarily pass control to XEDIT:

/* SASXEDIT SASMACRO - a SAS REXX macro     */
/*                     that invokes XEDIT   */
parse upper arg argstring
address command 'XEDIT' argstring

The following program named SASSUB XEDIT shows how to temporarily pass control to SAS SUBSET:

/* SASSUB XEDIT - an XEDIT macro            */
/*                that enters SAS SUBSET    */
address sas '++SAS'
/* use CMSRETURN; to get back to XEDIT      */
exit rc

From the Program Editor window, submit the following statement:


This invokes SASXEDIT SASMACRO, which invokes an XEDIT session. At the XEDIT command line type:


This invokes SASSUB XEDIT, which in turn invokes SAS SUBSET in the Program Editor window as a continuation of your SAS session. Next submit this SAS statement:


This ends SAS SUBSET and resumes XEDIT, which runs the remaining portion of SASSUB XEDIT and then resumes your XEDIT session. Ending the XEDIT session (using FILE or QUIT) passes control back to the original SAS session, which runs the remaining portion of SASXEDIT SASMACRO and then returns to the Program Editor window.

Flow of Control illustrates the flow of control among the original SAS session, the XEDIT session, and the SAS SUBSET session.

Flow of Control


Chapter Contents



Top of Page

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