Definition of DATA Step Statements

Definition

A SAS DATA step statement is a type of SAS language element that runs within a SAS DATA step and is part of the SAS DATA step programming language.

A SAS DATA step is a group of SAS language elements that begins with a DATA statement and ends with a RUN statement. The DATA statement is followed by other programming language elements such as more DATA step statements, functions, data set options, formats, and informats. These language elements are used to read, transform, and write data.

DATA step code block with SAS language elements statements, functions, formats and informats, and data set options

Summary of DATA step functionality:

Executable and Declarative Statements

DATA step statements are executable or declarative statements that can appear in the DATA step and run in SAS. The difference between these 2 types of statements is based on when the statements take effect — during compile-time or during program execution.

For more information about the phases of DATA step processing, see Flow of Action in SAS Programmer’s Guide: Essentials.

Declarative statements

Declarative statements supply information to SAS and take effect during the compilation phase of DATA step processing. Declarative statements are often referred to as “compile-time only” statements. They supply information to the program data vector (PDV) about the variables to be written to output and they determine the attributes of the variables.

Declarative statements also help SAS executable statements know what rows to read during iterations. They are therefore critical because when this variable information is determined at compile time, the attributes are set and cannot be changed. This is also why these compile-time only statements cannot be conditionally executed: they take effect at compile time before the DATA step executes.

For example, although the WHERE statement is specified within a DATA step and the statement might appear to be in effect, it is actually a declarative statement that takes effect during compile time. The WHERE statement is declarative because it supplies SAS with information needed by executable statements such as SET, MERGE, and MODIFY.

Executable statements

Executable statements result in some action during individual iterations of the DATA step. They take effect at the execution phase, after the program has already been compiled. Executable statements control all the looping and flow of the program.

The following tables show the executable and declarative statements that you can use in the SAS DATA step.

Executable Statements in the DATA Step

Executable Statements

ABORT

IF-THEN/ELSE

PUT, Formatted

Array Reference

INFILE

PUT, List

Assignment

INPUT

PUT, Named

CALL

GOTO

PUT

CONTINUE

INPUT, Column

PUT, ODS

DELETE

INPUT, Formatted

PUTLOG

DESCRIBE

INPUT, List

REDIRECT

DISPLAY

INPUT, Named

REMOVE

DO

LEAVE

REPLACE

DO, Iterative

LINK

RESETLINE

DO UNTIL

LIST

RETURN

DO WHILE

LOSTCARD

SELECT

ERROR

MERGE

SET

EXECUTE

MODIFY

STOP

FILE

Null

Sum

FILE, ODS

OUTPUT

UPDATE

IF, Subsetting

PUT, Column

Declarative Statements in the DATA Step

Declarative Statements

ARRAY

DATALINES4

Labels, Statement

ATTRIB

DROP

LENGTH

BY

END

RENAME

CARDS

FORMAT

RETAIN

CARDS4

INFORMAT

WHERE

DATA

KEEP

WINDOW

DATALINES

LABEL

DATA step statements can be grouped into functional categories. For a list of DATA step statements by category, see DATA Step Statements by Category.

Last updated: June 17, 2025