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 |
In addition to being either executable or declarative, SAS DATA step statements can be grouped into five functional categories:
Statements in this category | let you | |
---|---|---|
Action |
| |
Control |
| |
File-handling |
| |
Information |
| |
Window Display |
|
The following table lists and briefly describes the DATA step statements by category.
Category | Statement | Description |
---|---|---|
Action | 'ABORT Statement' on page 1098 | Stops executing the current DATA step, SAS job, or SAS session |
'Assignment Statement' on page 1108 | Evaluates an expression and stores the result in a variable | |
'CALL Statement' on page 1117 | Invokes or calls a SAS CALL routine | |
'DECLARE Statement' on page 1133 | Declares a DATA step component object; creates an instance of and initializes data for a DATA step component object | |
'DELETE Statement' on page 1137 | Stops processing the current observation | |
'DESCRIBE Statement' on page 1139 | Retrieves source codefrom a stored compiled DATA step program or a DATA step view | |
'ERROR Statement' on page 1153 | Sets _ERROR_ to 1 and, optionally , writes a message to the SAS log | |
'EXECUTE Statement' on page 1154 | Executes a stored compiled DATA step program | |
'IF Statement, Subsetting' on page 1212 | Continues processing only those observations that meet the condition | |
'LIST Statement' on page 1295 | Writes to the SAS log the input data record for the observation that is being processed | |
'LOSTCARD Statement' on page 1301 | Resynchronizes the input data when SAS encounters a missing or invalid record in data that has multiple records per observation | |
'_NEW_ Statement' on page 1325 | Creates an instance of a DATA step component object | |
'Null Statement' on page 1328 | Signals the end of data lines; acts as a placeholder | |
'OUTPUT Statement' on page 1339 | Writes the current observation to a SAS data set | |
'PUTLOG Statement' on page 1371 | Writes a message to the SAS log | |
'REDIRECT Statement' on page 1373 | Points to different input or output SAS data sets when you execute a stored program | |
'REMOVE Statement' on page 1375 | Deletes an observation from a SAS data set | |
'REPLACE Statement' on page 1378 | Replaces an observation in the same location | |
'STOP Statement' on page 1405 | Stops execution of the current DATA step | |
'Sum Statement' on page 1406 | Adds the result of an expression to an accumulator variable | |
'WHERE Statement' on page 1419 | Selects observations from SAS data sets that meet a particular condition | |
Control | 'CONTINUE Statement' on page 1123 | Stops processing the current DO-loop iteration and resumes with the next iteration |
'DO Statement' on page 1143 | Designates a group of statements to be executed as a unit | |
'DO Statement, Iterative' on page 1144 | Executes statements between DO and END repetitively based on the value of an index variable | |
'DO UNTIL Statement' on page 1148 | Executes statements in a DO loop repetitively until a condition is true | |
'DO WHILE Statement' on page 1149 | Executes statements repetitively while a condition is true | |
'END Statement' on page 1151 | Ends a DO groupor a SELECT group | |
'GO TO Statement' on page 1210 | Moves execution immediately to the statement label that is specified | |
'IF-THEN/ELSE Statement' on page 1213 | Executes a SAS statement for observations that meet specific conditions | |
'Labels, Statement' on page 1279 | Identifies a statement that is referred to by another statement | |
'LEAVE Statement' on page 1280 | Stops processing the current loop and resumes with the next statement in sequence | |
'LINK Statement' on page 1294 | Jumps to a statement label | |
'RETURN Statement' on page 1386 | Stops executing statements at the current point in the DATA step and returns to a predetermined point in the step | |
'SELECT Statement' on page 1394 | Executes one of several statements or groups of statements | |
File-handling | 'BY Statement' on page 1112 | Controls the operation of a SET, MERGE, MODIFY, or UPDATE statement in the DATA step and sets up special grouping variables |
'CARDS Statement' on page 1118 | Indicates that data lines follow | |
'CARDS4 Statement' on page 1118 | Indicates that data lines that contain semicolons follow | |
'DATA Statement' on page 1124 | Begins a DATA step and provides names for any output SAS data sets | |
'DATALINES Statement' on page 1131 | Indicates that data lines follow | |
'DATALINES4 Statement' on page 1132 | Indicates that data lines that contain semicolons follow | |
'FILE Statement' on page 1155 | Specifies the current output file forPUT statements | |
'FILE, ODS Statement' on page 1169 | Creates an ODS output object by binding the data component to the table definition (template). Optionally, lists the variables to include in the ODS output and specifies options that control the way that the variables are formatted. | |
'INFILE Statement' on page 1222 | Identifies an external file to read with anINPUT statement | |
'INPUT Statement' on page 1245 | Describes the arrangement of values in the input data record and assigns input values to the corresponding SAS variables | |
'INPUT Statement, Column' on page 1260 | Reads input values from specified columns and assigns them to the corresponding SAS variables | |
'INPUT Statement, Formatted' on page 1263 | Reads input values with specified informats and assigns them to the corresponding SAS variables | |
'INPUT Statement, List' on page 1267 | Scans the input data record for input values and assigns them to the corresponding SAS variables | |
'INPUT Statement, Named' on page 1273 | Reads data values that appearafter a variable name that is followed by anequal sign and assigns them to corresponding SAS variables | |
'MERGE Statement' on page 1304 | Joins observations from two or more SAS data sets into single observations | |
'MODIFY Statement' on page 1307 | Replaces, deletes, and appends observations in an existing SAS data set in place; does not create an additional copy | |
'PUT Statement' on page 1342 | 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' on page 1358 | Writes variable values in the specified columns in the output line | |
'PUT Statement, Formatted' on page 1360 | Writes variable values with the specified format in the output line | |
'PUT Statement, List' on page 1364 | Writes variable values and the specified character strings in the output line | |
'PUT Statement, Named' on page 1368 | Writes variable values after the variable name and an equal sign | |
'PUT, ODS Statement' on page 1371 | Writes data values to a special buffer from which they can be written to the data component and formatted by ODS | |
'SET Statement' on page 1397 | Reads an observation from one or more SAS data sets | |
'UPDATE Statement' on page 1414 | Updates a master file by applying transactions | |
Information | 'ARRAY Statement' on page 1100 | Defines elements of an array |
'Array Reference Statement' on page 1105 | Describes the elements in an array to be processed | |
'ATTRIB Statement' on page 1109 | Associates a format, informat, label, and/or length with one or more variables | |
'DROP Statement' on page 1150 | Excludes variables from output SAS data sets | |
'FORMAT Statement' on page 1207 | Associates formats with variables | |
'INFORMAT Statement' on page 1242 | Associates informats with variables | |
'KEEP Statement' on page 1276 | Includes variables in output SAS data sets | |
'LABEL Statement' on page 1277 | Assigns descriptive labels to variables | |
'LENGTH Statement' on page 1281 | Specifies the number of bytes for storing variables | |
'MISSING Statement' on page 1306 | Assigns characters in your input data to represent special missing values for numeric data | |
'RENAME Statement' on page 1377 | Specifies new names for variables in output SAS data sets | |
'RETAIN Statement' on page 1381 | 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' on page 1139 | Displays a window that is created with the WINDOW statement |
'WINDOW Statement' on page 1424 | Creates customized windows for your applications |