A
SAS statement
is a series of items that may include keywords, SAS
This section covers two kinds of SAS statements:
those that are used in DATA step programming
those that are global in scope and can be used
Base SAS Procedures Guide gives detailed descriptions of the SAS statements that are specific to each SAS procedure. The Complete Guide to the SAS Output Delivery System gives detailed descriptions of the Output Delivery System (ODS) statements.
DATA step statements are executable or declarative statements that can appear in the DATA step. Executable statements result in some action during individual iterations of the DATA step; declarative statements supply information to SAS and take effect when the system compiles program statements.
The following tables show the SAS executable and declarative statements that you can use in the DATA step.
|
Executable Statements |
||
|---|---|---|
|
ABORT |
IF, Subsetting |
PUT |
|
assignment |
IF-THEN/ELSE |
PUT, Column |
|
CALL |
INFILE |
PUT, Formatted |
|
CONTINUE |
INPUT |
PUT, List |
|
DECLARE |
INPUT, Column |
PUT, Named |
|
DELETE |
INPUT, Formatted |
PUT, _ODS_ |
|
DESCRIBE |
INPUT, List |
PUTLOG |
|
DISPLAY |
INPUT, Named |
REDIRECT |
|
DO |
LEAVE |
REMOVE |
|
DO, Iterative |
LINK |
REPLACE |
|
DO Until |
LIST |
RETURN |
|
DO While |
LOSTCARD |
SELECT |
|
ERROR |
MERGE |
SET |
|
EXECUTE |
MODIFY |
STOP |
|
FILE |
_NEW_ |
Sum |
|
FILE, ODS |
Null |
UPDATE |
|
GO TO |
OUTPUT |
|
Declarative Statements |
||
|---|---|---|
|
ARRAY |
DATALINES |
LABEL |
|
Array Reference |
DATALINES4 |
Labels, Statement |
|
ATTRIB |
DROP |
LENGTH |
|
BY |
END |
RENAME |
|
CARDS |
FORMAT |
RETAIN |
|
CARDS4 |
INFORMAT |
WHERE |
|
DATA |
KEEP |
WINDOW |
Global statements
Other SAS software products have additional global statements that are used with those products. For information, see the SAS documentation for those products.
System options
are instructions that affect your SAS session. They control the way that SAS
The syntax for specifying system options in an OPTIONS statement is
OPTIONS option(s) ;
Here is an explanation of the syntax:
option
specifies one or more SAS system options that you want to change.
The following example shows how to use the system options NODATE and LINESIZE= in an OPTIONS statement:
options nodate linesize=72;
Operating Environment Information: On the command line or in a configuration file, the syntax is specific to your operating environment. For details, see the SAS documentation for your operating environment.
Operating Environment Information:
SAS system options are
To determine which settings are in effect for SAS system options, use one of the following:
OPLIST system option
VERBOSE
writes to the SAS log the system options that were specified in the configuration file and on the SAS invocation command line.
SAS System Options window
lists all system option settings.
OPTIONS procedure
writes system option settings to the SAS log. To display the settings of system options with a specific functionality, such as error handling, use the
proc options GROUP=errorhandling;
run;
(See Base SAS Procedures Guide for more information.)
GETOPTION function
returns the value of a specified system option.
VOPTION DICTIONARY table
lists in the SASHELP library, all current system option settings. You can view this table with SAS Explorer, or you can extract information from the VOPTION table using PROC SQL.
dictionary.options SQL table
accessed with the SQL procedure, lists the system options that are in effect.
To determine which system options are restricted by your system administrator, use the RESTRICT option of the OPTIONS procedure. The RESTRICT option display the option's value, scope, and how it was set. In the following example, the SAS log shows that only one option, CMPOPT, is restricted:
proc options restrict; run;
Output 4.4: Restricted Option Information
|
|
1 proc options restrict;
2 run;
SAS (r) Proprietary Software Release 9.1 TS1B0
Option Value Information For SAS Option CMPOPT
Option Value: (NOEXTRAMATH NOMISSCHECK NOPRECISE NOGUARDCHECK)
Option Scope: SAS Session
How option value set: Site Administrator Restricted
|
|
The OPTIONS procedure will display this information for all options that are restricted. If your site administrator has not restricted any options, then the following message will appear in the SAS log:
Your site administrator has not restricted any options.
To determine how a system option value was set, use the OPTIONS procedure with the VALUE option specified in the OPTIONS statement. The VALUE option displays the specified option's value and scope. For example, the following statements write a message to the SAS log that
proc options option=center value; run;
The following partial SAS log shows that the option value for CENTER is the default that was shipped with the product..
Output 4.5: Option Value Information for the System Option CENTER
|
|
2 proc options option=center value;
3 run;
Option Value Information for SAS Option CENTER
Option Value: CENTER
Option Scope: NoReb
How option value set: Shipped Default
|
|
You can quickly obtain basic descriptive information about a system option by specifying the DEFINE option in the PROC OPTIONS statement.
The DEFINE option writes the following descriptive information about a system option to the SAS log:
description
type
when in the SAS session it can be set
For example, the following statements write a message to the SAS log that contains descriptive information about the system option CENTER:
proc options option=center define; run;
This partial SAS log tells you specific information about the system option CENTER.
Output 4.6: Descriptive Information for the System Option CENTER
|
|
1 proc options option=center define;
2 run;
CENTER
Option Definition Information for SAS Option CENTER
Group= LISTCONTROL
Group Description: Procedure output and display settings
Description: Center SAS procedure output
Type: The option value is of type BOOLEAN
When Can Set: Startup or anytime during the SAS Session
Restricted: Your Site Administrator can restrict modification of this option
Optsave: Proc Optsave or command Dmoptsave will save this option.
|
|
SAS provides default settings for SAS system options. You can override the default settings of any unrestricted system option. Depending on the function of the system option, you can specify a setting in any of the following ways:
on the command line:
You can specify any unrestricted SAS system option setting either on the SAS command line or in a configuration file. If you use the same option settings frequently, it is usually more
in a configuration file: If you use the same option settings frequently, it is usually more convenient to specify the options in a configuration file, rather than on the command line.
in an OPTIONS statement:
You can specify an OPTIONS statement at any time during a session except within data lines or parmcard lines. Settings
in a SAS System Options window:
If you are in a windowing environment, type
options
in the toolbox or on the command line to
Operating Environment Information:
On UNIX, Open VMS, and z/OS
When you specify a SAS system option setting, the setting applies to all
data one;
set items;
run;
/* option applies to all subsequent steps */
options obs=5;
/* printing ends with the fifth observation */
proc print data=one;
run;
/* the SET statement stops reading
after the fifth observation */
data two;
set items;
run;
To read more than five observations, you must reset the OBS= system option. For more information about the "OBS= System Option", see SAS Language Reference: Dictionary .
If a system option appears in more than one place, the order of precedence from highest to
OPTIONS statement and SAS System Options window
autoexec file (that contains an OPTIONS statement)
command-line specification
configuration file specification
SAS system default settings.
Operating Environment Information: In some operating environments, you can specify system options in other places. See the SAS documentation for your operating environment.
Table 4.9 on page 75 shows the order of precedence that SAS uses for execution mode options. These options are a subset of the SAS invocation options and are specified on the command line during SAS invocation.
|
Execution Mode Option |
Precedence |
|---|---|
|
OBJECTSERVER |
Highest |
|
DMR |
2nd |
|
INITCMD |
3rd |
|
DMS |
3rd |
|
DMSEXP |
3rd |
|
EXPLORER |
3rd |
The order of precedence of SAS execution mode options consists of the following rules:
SAS uses the execution mode option with the highest precedence.
If you specify more than one execution mode option of equal precedence, SAS uses only the last option listed.
See the descriptions of the individual options for more details.
Some system options share the same
In this example, the OBS= system option in the OPTIONS statement specifies that only the first 100 observations will be read from any data set within the SAS job. The OBS= data set option in the SET statement, however, overrides the system option and specifies that only the first five observations will be read from data set TWO. The PROC PRINT step uses the system option setting and reads and prints the first 100 observations from data set THREE:
options obs=100;
data one;
set two(obs=5);
run;
proc print data=three;
run;
Note the differences between system options, data set options, and statement options.
system options
remain in effect for all DATA and PROC steps in a SAS job or current process unless they are respecified.
data set options
apply to the processing of the SAS data set with which they appear. Some data set options have corresponding system options or LIBNAME statement options. For an individual data set, you can use the data set option to override the setting of these other options.
statement options
control the action of the statement in which they appear. Options in global statements, such as in the LIBNAME statement, can have a broader impact.