Previous Page | Next Page

Introducing the SAS Environment

Selecting a SAS Processing Mode


Processing Modes and Categories

All four modes that you can use to run SAS belong to one of two categories:

The following figure shows the four different modes and the processing types they belong to. As your processing requirements change, you might find it helpful to change from one processing mode to another.

Modes of Running SAS during Foreground or Background Processing

[Modes of Running SAS during Foreground or Background Processing]


Understanding Foreground Processing

Foreground processing includes all the ways that you can run SAS in except batch mode. Foreground processing begins immediately, but as your program runs, your current workstation session is occupied, so you can not use it to do anything else.(footnote 1) With foreground processing, you can route your output to the workstation display, to a file, to a printer, or to tape.

If you can answer yes to one or more of the following questions, then you might want to consider foreground processing:


Understanding Background Processing

Batch processing is the only way to run SAS in the background. Your operating environment coordinates all the work, so you can use your workstation session to do other work at the same time that your program runs. However, because the operating environment also schedules your program for execution and assigns it a priority, the program may have to wait in the input queue (the operating environment's list of jobs to be run) before it is executed. When your program runs to completion, you can browse, delete, or print your output.

Background processing may be required at your site. In addition, consider the following questions:

If you answer yes to one or more of these questions, then you might want to choose background processing.

Processing in the SAS Windowing Environment


Overview of Processing in the SAS Windowing Environment

The SAS windowing environment is a graphical user interface (GUI) that consists of a series of windows with which you can organize files and folders, edit and execute programs, view program output, and view messages about your programs and your SAS session.

Because it is an interactive and graphical facility, you can use a single session to prepare and submit a program and, if necessary, to modify and resubmit the program after browsing the output and messages. You can move from window to window and even interrupt and return to a session at the same point you left it.


General Characteristics

The SAS windowing environment is the default environment for a SAS session (unless your environment is customized at your site).

Note:   Because it is the default environment, many topics in this documentation describe tasks as you would perform them in the SAS windowing environment.  [cautionend]

The five most commonly used windows in the SAS windowing environment are Explorer, Results, Editor, Log, and Output.

Explorer

is a hierarchical system of folders, subfolders, and individual items. It provides a primary graphical interface to SAS from which you can do the following:

  • access and work with data, such as catalogs, tables, libraries, and operating environment files

  • open SAS programming windows

  • access the Output Delivery System (ODS)

  • create and define customized folders

You can use Explorer to view or set libraries and file shortcuts, view or set library members and catalog entries, or open and edit SAS files.

Note that when you start the SAS windowing environment, the Explorer might appear as a single-paned window that lists libraries that are currently available. You can add a navigational tree to the Explorer window by selecting View [arrow] Show Tree or by issuing the TREE command.

Editor or Program Editor

provides an area to enter, edit, and submit SAS statements and to save SAS source files.

Log

enables you to browse and scroll the SAS log. The SAS log provides messages about what is happening in your SAS session.

Output

enables you to browse and scroll procedure output.

Results

enables you to browse and manipulate an index of your procedure output.

SAS Windowing Environment: SAS Explorer, Log and Editor Windows, (Windows Operating System)

[SAS Windowing Environment: SAS Explorer, Log and Editor Windows, (Windows Operating System)]

Note:   Together, the Program Editor, Log, and Output windows are sometimes referred to as the programming windows.  [cautionend]

Additional windows are also available in the SAS windowing environment that enable you to do the following:

For more information about these windows and about performing tasks in the windowing environment, see Using the SAS Windowing Environment.


Invoking the SAS Windowing Environment

To invoke the SAS windowing environment, execute the SAS command followed by any system options that you want to put into effect. The SAS windowing environment is set as the default method of operation for SAS, but it may not be the default setting at your work site.

If the SAS windowing environment is not the default method of operation, you can specify the DMSEXP option in the SAS command. Or, you can include the DMSEXP option in the configuration file, which contains settings for system options. For more information about the configuration file, see Customizing SAS Sessions and Programs at Startup.

You specify options in the SAS command as you do any other command options on your system. The following table shows how you would start the SAS windowing environment and specify the DMSEXP option under various operating environments:

Operating Environment Command
z/OS sas options ('dmsexp')
Windows sas -dmsexp
UNIX sas -dmsexp
OpenVMS sas /dmsexp
CMS sas (dmsexp

For details about how to specify command options on other systems, see the SAS documentation for your operating environment.


Ending a SAS Windowing Environment Session

You can end your SAS windowing environment session with the BYE or ENDSAS command. Specify BYE or ENDSAS on the SAS command line, and then execute the command by pressing ENTER or RETURN (depending on which operating environment you use).

You can also end your session with the ENDSAS statement in the Program Editor window. Type the following statement on a data line and submit it for execution:

endsas;


Interrupting a SAS Windowing Environment Session

You might occasionally find it necessary to return to your operating environment from a SAS session. If you do not want to end your SAS session, then you can escape to the operating environment by issuing the X command. Simply execute the following command on the command line:

x

From your operating environment, you can then return to the same SAS session as you left it, by executing the appropriate operating environment command. For example, under the z/OS operating environment, the operating environment command is RETURN or END; under the OpenVMS operating environment, the command is LOGOFF.

Use this form of the X command to execute a single operating environment command:

X operating-environment-command

or, if the command contains embedded blanks,

X 'operating-environment-command'

For example, on many systems you can display the current time by specifying

x time

After the command executes, you can take the appropriate action to return to your SAS session.

For information about interrupting a SAS session in other operating environments, see the SAS documentation for your operating environment.


Processing Interactively in Line Mode


General Characteristics

With line mode processing, you enter programming statements one line at a time; DATA and PROC steps are executed after you enter a RUN statement, or after another step boundary. Program messages and output appear on the monitor.

You can modify program statements only when you first enter them, before you press ENTER or RETURN, which means that you must type your entries carefully.


Invoking SAS in Line Mode

To invoke SAS in line mode, execute the SAS command followed by any system options that you want to put into effect. The NODMS system option activates an interactive line mode session. If NODMS is not the default system option at your site, you can either specify the option with the SAS command or include the NODMS specification in the configuration file, the file that contains settings for system options that are put into effect at invocation. The following table shows you how to specify the NODMS system option with the SAS command under various operating environments.

Operating environment Command
z/OS sas options ('nodms')
UNIX sas -nodms
OpenVMS sas /nodms
CMS sas (nodms)


Using the Run Statement to Execute a Program in Line Mode

In line mode, DATA steps are executed only when a new step boundary is encountered. This occurs after you enter a RUN DATA or PROC statement. In other words, if you submit DATA X; X=1; in the windowing environment, then you will not see execution until the next RUN DATA or PROC statement is submitted.

At the beginning of each line, SAS prompts you with a number and a question mark to enter more statements. If you use a DATALINES statement, then a greater-than symbol (>) replaces the question mark, indicating that data lines are expected.

When you are using line mode, the log will be easier to read if you follow this programming tip: cause each DATA or PROC step to execute before you begin entering programming statements for the next step. Either an END statement or a semicolon that marks the end of datalines causes a step to execute immediately.


Ending a Line Mode SAS Session

To end your session, type endsas; at the SAS prompt, then press ENTER or RETURN. Your session ends, and you are returned to your operating environment.


Interrupting a Line Mode SAS Session

In line mode, you can escape to the operating environment by executing the following statement:

x;

You can return to your SAS session by executing the appropriate operating environment command. Use this form of the X statement to execute a single operating environment command:

X operating-environment-command;

or, if the command contains embedded blanks,

X 'operating-environment-command';

For example, on many systems you can display the current time by specifying

x time;

When you use this form of the X command, the command executes, and you are returned to your SAS session.


Processing in Batch Mode

The first step in executing a program in batch mode is to prepare files that include:

Then you submit your file to the operating environment, and your workstation session is free for other work while the operating environment executes the program. This is called background processing because you cannot view or change the program in any way until after it executes. The log and output are routed to the destination that you specify in the operating environment control language; without a specification, they are routed to the default. For examples of batch processing, see the SAS documentation for your operating environment.


Processing Noninteractively


General Characteristics

Noninteractive processing has some characteristics of interactive processing and some of batch processing. When you process noninteractively, you execute SAS program statements that are stored in an external file. You use a SAS command to submit the program statements to your operating environment.

Note:   The SAS command is implemented differently under each operating environment. For example, under z/OS the command is typically a CLIST, and under CMS it is an EXEC.  [cautionend]

As in interactive processing, processing begins immediately, and your current workstation session is occupied. However, as with batch processing, you cannot interact with your program.

Note:   For some exceptions to this, see the SAS documentation for your operating environment.  [cautionend]

You can see the log or procedure output immediately after the program has run. Log and listing output are routed to the workstation, unlike the SAS windowing environment, where you must explicitly save output to a file. If you decide that you must correct or modify your program, then you must use an editor to make necessary changes and then resubmit your program.


Executing a Program in Noninteractive Mode

When you run a program in noninteractive mode, you do not enter a SAS session as you do in interactive mode; instead of starting a SAS session, you are executing a SAS program. The first step is to enter the SAS statements in a file, just as you would for a batch job. Then, at the system prompt, you specify the SAS command followed by the complete name of the file and any system options that you want to specify.

The following example executes the SAS statements in the member TEMP in the partitioned data set your-userid.UGWRITE.TEXT in the z/OS operating environment:

sas input(ugwrite.text(temp))

Note that the INPUT operand points to the file that contains the SAS statements for a noninteractive session.

The next example executes the SAS statements that are stored in the subdirectory [USERID.UGWRITE.TEXT] on the OpenVMS operating environment in the file TEMP.SAS:

$ sas [userid.ugwrite.text] temp

SAS looks for the file on the current disk.

The following example executes the SAS statements in the CMS file TEMP SAS A:

sas temp

Note:   Note that in CMS, SAS looks for filetype SAS on any accessed disk. CMS executes the first file called temp that it finds on any accessible mini disk. If TEMP SAS lives on disk 'G', then it will still be executed.  [cautionend]

For details about how to use noninteractive mode on other operating environments, see the SAS documentation for your operating environment. Consult your SAS Site Representative for information specific to your site.

Browsing the Log and Output

Log and output information either appears in your workstation display or it is sent to a file. The default action is dependent on your operating environment. In either case, you can browse the information within your display or by opening the appropriate file.

See your operating environment documentation for more information.


FOOTNOTE 1:   In a workstation environment, you can switch to another window and continue working. [arrow]

Previous Page | Next Page | Top of Page