PUT Statement for ODS

Writes data values to a special buffer from which they can be written to the data component and then formatted by ODS.
Valid in: DATA step
Category: File-handling
Type: Executable
Requirement: If you use the _ODS_ option in the PUT statement, then you must use the FILE PRINT ODS statement.
Note: This syntax shows only the ODS form of the PUT statement when you are binding to a template. For the complete syntax, see the PUT Statement in SAS Statements: Reference.

Syntax

PUT <specification> <_ODS_> <@|@@> ;

Optional Arguments

specification
specifies one or more variables to write and where to write them. specification has the following form:
<ods-pointer-control-1> variable-1 <...<ods-pointer-control-n> variable-n>
ods-pointer-control
moves the pointer in the buffer to a specified line or column.
variable
identifies the variable to write.
_ODS_
specifies that the PUT statement writes values to the data component for each of the variables that were defined as columns with the FILE PRINT ODS COLUMNS= statement.
Default:The order of these columns is determined by the order that is specified by the COLUMNS= suboption in the FILE PRINT ODS statement. If you omit the COLUMNS= suboption, then the order of the variables in the program data vector determines their order in the output object.
Requirement:If you specify the _ODS_ option, then you must use the FILE PRINT ODS statement and the FILE PRINT ODS statement must precede the PUT _ODS_ statement.
Interaction:You can use _ODS_ in a PUT statement that specifies the placement of individual variables. _ODS_ writes to a particular row and column only if another PUT statement has not already written a variable to that same row and column. The position of _ODS_ in the PUT statement does not affect the outcome in the data component.
Tip:By default, the order of the columns in the data component matches the order of the columns in the buffer. However, if you have specified a table definition, it might override this order. For more information, see the discussion of ORDER_DATA.
See:For more information, see ODS<=(ODS-suboptions)>.
@ | @@
holds an output line for the execution of the next PUT statement across iterations of the DATA step. The line-hold specifiers are called trailing @ and double trailing @.
Default:If you do not use @ or @@, then each PUT statement in a DATA step writes a new line to the buffer.

Details

ODS Column Pointer Controls

ODS column pointer controls differ slightly from column pointer controls in a PUT statement that does not use ODS. An ODS column refers not to a single character space but to a column that contains an entire variable value. Therefore, an ODS column pointer control moves from one entire value to the next, not from one character space to another. Column 1 contains values for the first variable in the output; column 2 contains values for the second variable, and so on.
ODS column pointer controls have the following general forms:
@ods-column
moves the pointer to the specified ODS column. ods-column is a number, a numeric variable, or an expression that identifies the column to write to.
Default:If ods-column exceeds the number of columns in the data component, then ODS writes the current line, moves the pointer to the first ODS column on the next line, and continues to process the PUT statement.
Requirement:If ods-column is a number, then it must be a positive integer. If ods-column is a numeric variable or an expression, then SAS treats it as follows. If ods-column is not an integer, then SAS truncates the decimal portion and uses only the integer value. If ods-column is 0 or negative, then SAS moves the pointer to column 1.
Tip:You can alter the default behavior with options in the FILE PRINT ODS statement. For more information, see the discussion of overflow control.
+ods-column
moves the pointer by the specified number of ODS columns. ods-column is a number, a numeric variable, or an expression that specifies the number of columns to move the pointer.
Requirement:If ods-column is a number, then it must be an integer. If ods-column is a numeric variable or an expression, then it does not have to be an integer. If it is not an integer, then SAS truncates the decimal portion and uses only the integer value. If ods-column is a positive integer, SAS moves the pointer to the right. If ods-column is a negative integer, SAS moves the pointer to the left. If ods-column is 0, SAS does not move the pointer.
Tip:If the current column position becomes less than 1, then the pointer moves to column 1. If the current column position exceeds the number of columns in the data component, then ODS writes the current line, moves the pointer to the first ODS column on the next line, and continues to process the PUT statement.
@ 'column-name'
moves the pointer to the ODS column identified by 'column-name'. The column name is a data component variable name.
Requirement:column-name must be enclosed in quotation marks.

ODS Line Pointer Controls

Line pointer controls in a DATA step that uses ODS are the same as line pointer controls in a DATA step that does not use ODS. However, you can use only those listed below with ODS. Line pointer controls have the following general forms:
#line
moves the pointer to the specified line. line is a number, a numeric variable, or an expression that identifies the line to write to.
Requirement:If line is a number, then it must be an integer. If line is a numeric variable or an expression, it does not have to be an integer. If it is not an integer, then SAS truncates the decimal portion and uses only the integer value.
/
moves the pointer to the first column of the next line.
Note: If you use a line pointer control to skip lines in ODS output, then all columns that are not referenced on the current line, or skipped lines, are set to a missing value. Columns that contain numeric values display a period for the missing value. If you prefer not to include these periods in your ODS output, you can display missing numeric values as a blank by using the MISSING statement (or the MISSING= system option). For more information about the statement, see MISSING Statement in SAS Statements: Reference. For more information about the system option, see MISSING= System Option in SAS System Options: Reference.

When the Pointer Moves Past the End of a Line

In a DATA step that uses ODS, the number of columns in the buffer and in the data component are determined in one of three ways:
  • By default, the number of variables in the program data vector determines the number of ODS columns.
  • You can override the default by defining ODS columns with the COLUMNS= suboption in the FILE PRINT ODS statement.
  • If you associate a template with the data component, then the specifications in the template take precedence. As a result, the number of columns that actually appear in the output object could change.
When using pointer controls and the @ or @@, you might inadvertently position the pointer beyond the last ODS column. You can control how SAS handles this situation with options in the FILE PRINT ODS statement. For more information, see the discussion of overflow control.