Previous Page | Next Page

Statements

DATA Step Statements


Executable and Declarative 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, Column
Array Reference IF-THEN/ELSE PUT, Formatted
Assignment INFILE PUT, List
CALL INPUT PUT, Named
CONTINUE GO TO PUT
DECLARE INPUT, Column PUT, ODS
DELETE INPUT, Formatted PUTLOG
DESCRIBE INPUT, List REDIRECT
DISPLAY INPUT, Named REMOVE
DO LEAVE REPLACE
DO, Iterative LINK RETURN
DO UNTIL LIST SELECT
DO WHILE LOSTCARD SET
ERROR MERGE STOP
EXECUTE MODIFY Sum
FILE Null UPDATE
FILE, ODS OUTPUT

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 by Category

In addition to being either executable or declarative, SAS DATA step statements can be grouped into five functional categories:

Categories of DATA Step Statements
Statements Category Functionality
Action
  • create and modify variables

  • select only certain observations to process in the DATA step

  • look for errors in the input data

  • work with observations as they are being created


Control
  • skip statements for certain observations

  • change the order that statements are executed

  • transfer control from one part of a program to another


File-handling
  • work with files used as input to the data set

  • work with files to be written by the DATA step



Information
  • give SAS additional information about the program data vector

  • give SAS additional information about the data set or data sets that are being created.


Window Display
  • display and customize windows.

The following table lists and briefly describes the DATA step statements by category.

Categories and Descriptions of DATA Step Statements
Category Statement Description
Action ABORT Statement
Stops executing the current DATA step, SAS job, or SAS session.

Assignment Statement
Evaluates an expression and stores the result in a variable.

CALL Statement
Invokes a SAS CALL routine.

DECLARE Statement, Hash and Hash Iterator Objects
Declares a hash or hash iterator object; creates an instance of and initializes data for a hash or hash iterator object.

DECLARE Statement, Java Object
Declares a Java object; creates an instance of and initializes data for a Java object.

DELETE Statement
Stops processing the current observation.

DESCRIBE Statement
Retrieves source code from a stored compiled DATA step program or a DATA step view.

ERROR Statement
Sets _ERROR_ to 1. A message written to the SAS log is optional.

EXECUTE Statement
Executes a stored compiled DATA step program .

IF Statement, Subsetting
Continues processing only those observations that meet the condition of the specified expression.

LIST Statement
Writes to the SAS log the input data record for the observation that is being processed.

LOSTCARD Statement
Resynchronizes the input data when SAS encounters a missing or invalid record in data that has multiple records per observation.

Null Statement
Signals the end of data lines or acts as a placeholder.

OUTPUT Statement
Writes the current observation to a SAS data set.

PUTLOG Statement
Writes a message to the SAS log.

REDIRECT Statement
Points to different input or output SAS data sets when you execute a stored program.

REMOVE Statement
Deletes an observation from a SAS data set.

REPLACE Statement
Replaces an observation in the same location.

STOP Statement
Stops execution of the current DATA step.

Sum Statement
Adds the result of an expression to an accumulator variable.

WHERE Statement
Selects observations from SAS data sets that meet a particular condition.
Control CONTINUE Statement
Stops processing the current DO-loop iteration and resumes processing the next iteration.

DO Statement
Specifies a group of statements to be executed as a unit.

DO Statement, Iterative
Executes statements between the DO and END statements repetitively, based on the value of an index variable.

DO UNTIL Statement
Executes statements in a DO loop repetitively until a condition is true.

DO WHILE Statement
Executes statements in a DO-loop repetitively while a condition is true.

END Statement
Ends a DO group or SELECT group processing.

GO TO Statement
Directs program execution immediately to the statement label that is specified and, if followed by a RETURN statement, returns execution to the beginning of the DATA step.

IF-THEN/ELSE Statement
Executes a SAS statement for observations that meet specific conditions.

Labels, Statement
Identifies a statement that is referred to by another statement.

LEAVE Statement
Stops processing the current loop and resumes with the next statement in the sequence.

LINK Statement
Directs program execution immediately to the statement label that is specified and, if followed by a RETURN statement, returns execution to the statement that follows the LINK statement.

RETURN Statement
Stops executing statements at the current point in the DATA step and returns to a predetermined point in the step.

SELECT Statement
Executes one of several statements or groups of statements.
File-handling BY Statement
Controls the operation of a SET, MERGE, MODIFY, or UPDATE statement in the DATA step and sets up special grouping variables.

CARDS Statement
Specifies that data lines follow.

CARDS4 Statement
Specifies that data lines that contain semicolons follow.

DATA Statement
Begins a DATA step and provides names for any output SAS data sets, views, or programs.

DATALINES Statement
Specifies that data lines follow.

DATALINES4 Statement
Indicates that data lines that contain semicolons follow.

FILE Statement
Specifies the current output file for PUT statements.

INFILE Statement
Specifies an external file to read with an INPUT statement.

INPUT Statement
Describes the arrangement of values in the input data record and assigns input values to the corresponding SAS variables.

INPUT Statement, Column
Reads input values from specified columns and assigns them to the corresponding SAS variables.

INPUT Statement, Formatted
Reads input values with specified informats and assigns them to the corresponding SAS variables.

INPUT Statement, List
Scans the input data record for input values and assigns them to the corresponding SAS variables.

INPUT Statement, Named
Reads data values that appear after a variable name that is followed by an equal sign and assigns them to corresponding SAS variables.

MERGE Statement
Joins observations from two or more SAS data sets into a single observation.

MODIFY Statement
Replaces, deletes, and appends observations in an existing SAS data set in place but does not create an additional copy.

PUT Statement
Writes lines to the SAS log, to the SAS output window, or to an external location that is specified in the most recent FILE statement.

PUT Statement, Column
Writes variable values in the specified columns in the output line.

PUT Statement, Formatted
Writes variable values with the specified format in the output line.

PUT Statement, List
Writes variable values and the specified character strings in the output line.

PUT Statement, Named
Writes variable values after the variable name and an equal sign.

SET Statement
Reads an observation from one or more SAS data sets.

UPDATE Statement
Updates a master file by applying transactions.
Information ARRAY Statement
Defines the elements of an array.

Array Reference Statement
Describes the elements in an array to be processed.

ATTRIB Statement
Associates a format, informat, label, and length with one or more variables.

DROP Statement
Excludes variables from output SAS data sets.

FORMAT Statement
Associates formats with variables.

INFORMAT Statement
Associates informats with variables.

KEEP Statement
Specifies the variables to include in output SAS data sets.

LABEL Statement
Assigns descriptive labels to variables.

LENGTH Statement
Specifies the number of bytes for storing variables.

MISSING Statement
Assigns characters in your input data to represent special missing values for numeric data.

RENAME Statement
Specifies new names for variables in output SAS data sets.

RETAIN Statement
Causes a variable that is created by an INPUT or assignment statement to retain its value from one iteration of the DATA step to the next.
Window Display DISPLAY Statement
Displays a window that is created with the WINDOW statement.

WINDOW Statement
Creates customized windows for your applications.

Previous Page | Next Page | Top of Page