DATA Step Statements by Category

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

Categories of DATA Step Statements

Statements Category

Functionality

Action

  • Creates and modifies variables.
  • Selects only certain observations to process in the DATA step.
  • Looks for errors in the input data.
  • Works with observations as they are being created.

See Action for a list of statements.

CAS

  • Specifies statements that run on the CAS server.

See CAS for a list of statements.

Control

  • Skips statements for certain observations.
  • Changes the order that statements are executed.
  • Transfers control from one part of a program to another.

See Control for a list of statements.

File-Handling

  • Works with files used as input to the data set.
  • Works with files to be written by the DATA step.

See File-Handling for a list of statements.

Information

  • Gives SAS additional information about the program data vector.
  • Gives SAS additional information about the data set or data sets that are being created.

See Information for a list of statements.

Window Display

  • Displays and customizes windows.

See Window Display for a list of statements.

Some statements run in SAS only, and some statements run in SAS and on the CAS server. If CAS is specified for the statement category, then the statement runs in SAS and on the CAS server. If CAS is not specified for the statement category, then the statement runs in SAS only. For example, the DO statement runs in SAS and on the CAS server, so CAS is specified as a category. The ABORT statement runs in SAS only, so CAS is not specified as a category.

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

Category Language Elements Description
ActionABORT StatementStops executing the current DATA step, SAS job, or SAS session.
Assignment StatementEvaluates an expression and stores the result in a variable.
CALL StatementInvokes a SAS CALL routine.
DELETE StatementStops processing the current observation.
DESCRIBE StatementRetrieves source code from a stored compiled DATA step program or a DATA step view.
ERROR StatementSets _ERROR_ to 1. A message written to the SAS log is optional.
EXECUTE StatementExecutes a stored compiled DATA step program.
IF Statement: SubsettingContinues processing only those observations that meet the condition of the specified expression.
LIST StatementWrites to the SAS log the input data record for the observation that is being processed.
LOSTCARD StatementResynchronizes the input data when SAS encounters a missing or invalid record in data that has multiple records per observation.
OUTPUT StatementWrites the current observation to a SAS data set.
PUTLOG StatementWrites a message to the SAS log.
REDIRECT StatementPoints to different input or output SAS data sets when you execute a stored program.
REMOVE StatementDeletes an observation from a SAS data set.
REPLACE StatementReplaces an observation in the same location.
STOP StatementStops execution of the current DATA step.
Sum StatementAdds the result of an expression to an accumulator variable.
WHERE StatementSelects observations from SAS data sets that meet a particular condition.
CASARRAY StatementDefines the elements of an array.
Array Reference StatementDescribes the elements in an array to be processed.
Assignment StatementEvaluates an expression and stores the result in a variable.
ATTRIB StatementAssociates a format, informat, label, and length with one or more variables.
BY StatementControls the operation of a SET, MERGE, MODIFY, or UPDATE statement in the DATA step and sets up special grouping variables.
CALL StatementInvokes a SAS CALL routine.
CONTINUE StatementStops processing the current DO-loop iteration and resumes processing the next iteration.
DATA StatementBegins a DATA step and provides names for any output such as SAS data sets, views, or programs.
DELETE StatementStops processing the current observation.
DO StatementSpecifies a group of statements to be executed as a unit.
DO Statement: IterativeExecutes statements between the DO and END statements repetitively, based on the value of an index variable.
DO UNTIL StatementExecutes statements in a DO loop repetitively until a condition is true.
DO WHILE StatementExecutes statements in a DO loop repetitively while a condition is true.
DROP StatementExcludes variables from output SAS data sets.
END StatementEnds DO group or SELECT group processing.
ERROR StatementSets _ERROR_ to 1. A message written to the SAS log is optional.
FILE StatementSpecifies the current output file for PUT statements.
FORMAT StatementAssociates formats with variables.
GOTO StatementDirects 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 Statement: SubsettingContinues processing only those observations that meet the condition of the specified expression.
IF-THEN/ELSE StatementExecutes a SAS statement for observations that meet specific conditions.
INFORMAT StatementAssociates informats with variables.
KEEP StatementSpecifies the variables to include in output SAS data sets.
LABEL StatementAssigns descriptive labels to variables.
Label: StatementIdentifies a statement that is referred to by another statement.
LEAVE StatementStops processing the current loop and resumes with the next statement in the sequence.
LENGTH StatementSpecifies the number of bytes for storing character and numeric variables, or the number of characters for storing VARCHAR variables.
LINK StatementDirects 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.
LIST StatementWrites to the SAS log the input data record for the observation that is being processed.
LOSTCARD StatementResynchronizes the input data when SAS encounters a missing or invalid record in data that has multiple records per observation.
MERGE StatementJoins observations from two or more SAS data sets into a single observation.
OUTPUT StatementWrites the current observation to a SAS data set.
PUT StatementWrites 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: ColumnWrites variable values in the specified columns in the output line.
PUT Statement: FormattedWrites variable values with the specified format in the output line.
PUT Statement: ListWrites variable values and the specified character strings in the output line.
PUT Statement: NamedWrites variable values after the variable name and an equal sign.
PUTLOG StatementWrites a message to the SAS log.
RENAME StatementSpecifies new names for variables in output SAS data sets.
RETAIN StatementCauses 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.
RETURN StatementStops executing statements at the current point in the DATA step and returns to a predetermined point in the step.
SELECT StatementExecutes one of several statements or groups of statements.
SET StatementReads an observation from one or more SAS data sets.
STOP StatementStops execution of the current DATA step.
Sum StatementAdds the result of an expression to an accumulator variable.
WHERE StatementSelects observations from SAS data sets that meet a particular condition.
ControlCONTINUE StatementStops processing the current DO-loop iteration and resumes processing the next iteration.
DO StatementSpecifies a group of statements to be executed as a unit.
DO Statement: IterativeExecutes statements between the DO and END statements repetitively, based on the value of an index variable.
DO UNTIL StatementExecutes statements in a DO loop repetitively until a condition is true.
DO WHILE StatementExecutes statements in a DO loop repetitively while a condition is true.
END StatementEnds DO group or SELECT group processing.
GOTO StatementDirects 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 StatementExecutes a SAS statement for observations that meet specific conditions.
Label: StatementIdentifies a statement that is referred to by another statement.
LEAVE StatementStops processing the current loop and resumes with the next statement in the sequence.
LINK StatementDirects 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 StatementStops executing statements at the current point in the DATA step and returns to a predetermined point in the step.
SELECT StatementExecutes one of several statements or groups of statements.
File-HandlingBY StatementControls the operation of a SET, MERGE, MODIFY, or UPDATE statement in the DATA step and sets up special grouping variables.
CARDS StatementSpecifies that lines of data follow the statement.
CARDS4 StatementSpecifies that the lines of data that follow the statement contain internal semicolons.
DATA StatementBegins a DATA step and provides names for any output such as SAS data sets, views, or programs.
DATALINES StatementSpecifies that lines of data follow the statement.
DATALINES4 StatementSpecifies that the lines of data that follow the statement contain internal semicolons.
FILE StatementSpecifies the current output file for PUT statements.
INFILE StatementSpecifies an external file to read with an INPUT statement.
INPUT StatementDescribes the arrangement of values in the input data record and assigns input values to the corresponding SAS variables.
INPUT Statement: ColumnReads input values from specified columns and assigns the values to the corresponding SAS variables.
INPUT Statement: FormattedReads input values with specified informats and assigns them to the corresponding SAS variables.
INPUT Statement: ListScans the input data record for input values and assigns them to the corresponding SAS variables.
INPUT Statement: NamedReads data values that appear after a variable name that is followed by an equal sign and assigns the values to corresponding SAS variables.
MERGE StatementJoins observations from two or more SAS data sets into a single observation.
MODIFY StatementReplaces, deletes, and appends observations in an existing SAS data set in place but does not create an additional copy.
PUT StatementWrites 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: ColumnWrites variable values in the specified columns in the output line.
PUT Statement: FormattedWrites variable values with the specified format in the output line.
PUT Statement: ListWrites variable values and the specified character strings in the output line.
PUT Statement: NamedWrites variable values after the variable name and an equal sign.
SET StatementReads an observation from one or more SAS data sets.
UPDATE StatementUpdates a master file by applying transactions.
InformationARRAY StatementDefines the elements of an array.
Array Reference StatementDescribes the elements in an array to be processed.
ATTRIB StatementAssociates a format, informat, label, and length with one or more variables.
DROP StatementExcludes variables from output SAS data sets.
FORMAT StatementAssociates formats with variables.
INFORMAT StatementAssociates informats with variables.
KEEP StatementSpecifies the variables to include in output SAS data sets.
LABEL StatementAssigns descriptive labels to variables.
LENGTH StatementSpecifies the number of bytes for storing character and numeric variables, or the number of characters for storing VARCHAR variables.
RENAME StatementSpecifies new names for variables in output SAS data sets.
RETAIN StatementCauses 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 DisplayDISPLAY StatementDisplays a window that is created with the WINDOW statement.
WINDOW StatementCreates customized windows for your applications.
Last updated: June 17, 2025