SUPPORT / SAMPLES & SAS NOTES
 

Support

Usage Note 40887: Definition of step boundaries and the difference between a RUN statement and a QUIT statement

DetailsAboutRate It

When programming in SAS, step boundaries determine when programming statements, DATA steps, and PROC steps take effect.

The following are considered step boundaries in SAS:

   DATA statement
   ENDSAS statement
   PROC statement
   QUIT statement
   RUN statement
   The single semicolon (;) statement following a DATALINES statement
   The four semicolon (;;;;) statement following a DATALINES4 statement
   The very last line of a program in batch or noninteractive processing

SAS will execute programming statements or steps once a default or explicit step boundary is crossed. For example, if a DATA step is coded as the first step in a SAS program being run in an interactive (windowing) environment, in order for the DATA step to be executed it must find a step boundary such as a RUN statement or another DATA or PROC step. When SAS encounters the step boundary following the first DATA step, this step boundary statement triggers SAS to execute the preceding DATA step. If a RUN statement follows the first DATA Step, the RUN statement is an explicit step boundary. However, if a DATA or PROC step immediately follows the first DATA step that does not have a RUN statement, the DATA or PROC statement is a default step boundary for the first DATA step. When running SAS in an interactive (windowing) environment, the RUN statement must be the very last statement of the program in order for the last statement, DATA step, or PROC step to be executed.

Placing a RUN statement following each step in the program is not necessary. This is basically a coding preference and it will not affect processing time, but a RUN statement used with a global statement can affect the program. An example of this is using an OPTIONS statement and needing to use the same system option set to a different value for each step. For instance, you have two DATA steps each writing to two separate external files and need to use a LINESIZE=75 for the first DATA step and a LINESIZE=65 for the second DATA step. Before the first DATA step you will code an OPTIONS statement specifying LINESIZE=75. Following the first DATA step, make sure to code a RUN statement before the next OPTIONS statement (with the LINESIZE=65 setting) and the subsequent DATA step. This RUN is necessary to act as a step boundary for the first DATA step and to use the LINESIZE=75 setting. If a RUN statement is not specified following the first DATA step and before the second OPTIONS statement then the setting of LINESIZE=65 will be used for both DATA steps.

The difference between a RUN statement and a QUIT statement is that a RUN statement executes previously submitted SAS statements and a QUIT statement executes previously submitted SAS statements and ends the procedure. The QUIT statement is used for RUN-group processing that enables you to submit certain procedures with a RUN statement, but the RUN statement will not end the procedure. This allows you to continue to use the same procedure without submitting another procedure. With RUN-group processing you must submit either a RUN CANCEL or a QUIT statement to end the procedure. A few examples of Base SAS procedures that are RUN-group processing procedures are: CATALOG, DATASETS, and PLOT. The SQL procedure is similar but each query is automatically executed, and a RUN statement or RUN CANCEL statement have no effect. In order to end the SQL procedure, you must use a QUIT statement.

Further information regarding step boundaries can be found in the SAS Language Reference: Concepts. Information regarding the RUN statement can be found in the SAS Language Reference: Dictionary, and information about RUN_group processing and the QUIT statement can be found in the Base SAS Procedures Guide.



Operating System and Release Information

Product FamilyProductSystemSAS Release
ReportedFixed*
SAS SystemBase SASz/OS
Z64
OpenVMS VAX
Microsoft® Windows® for 64-Bit Itanium-based Systems
Microsoft Windows Server 2003 Datacenter 64-bit Edition
Microsoft Windows Server 2003 Enterprise 64-bit Edition
Microsoft Windows XP 64-bit Edition
Microsoft® Windows® for x64
OS/2
Microsoft Windows 95/98
Microsoft Windows 2000 Advanced Server
Microsoft Windows 2000 Datacenter Server
Microsoft Windows 2000 Server
Microsoft Windows 2000 Professional
Microsoft Windows NT Workstation
Microsoft Windows Server 2003 Datacenter Edition
Microsoft Windows Server 2003 Enterprise Edition
Microsoft Windows Server 2003 Standard Edition
Microsoft Windows Server 2003 for x64
Microsoft Windows Server 2008
Microsoft Windows Server 2008 for x64
Microsoft Windows XP Professional
Windows 7 Enterprise 32 bit
Windows 7 Enterprise x64
Windows 7 Home Premium 32 bit
Windows 7 Home Premium x64
Windows 7 Professional 32 bit
Windows 7 Professional x64
Windows 7 Ultimate 32 bit
Windows 7 Ultimate x64
Windows Millennium Edition (Me)
Windows Vista
Windows Vista for x64
64-bit Enabled AIX
64-bit Enabled HP-UX
64-bit Enabled Solaris
ABI+ for Intel Architecture
AIX
HP-UX
HP-UX IPF
IRIX
Linux
Linux for x64
Linux on Itanium
OpenVMS Alpha
OpenVMS on HP Integrity
Solaris
Solaris for x64
Tru64 UNIX
* For software releases that are not yet generally available, the Fixed Release is the software release in which the problem is planned to be fixed.