Previous Page | Next Page

Dictionary of ODS Language Statements

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 a 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.

Syntax
Options
Details
ODS Column Pointer Controls
ODS Line Pointer Controls
When the Pointer Moves Past the End of a Line
See Also

Syntax

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

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 Language Reference: Dictionary.  [cautionend]


Options

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.

See also: When the Pointer Moves Past the End of a Line
variable

identifies the variable to write.

Featured in: Example 4: Creating and Using a User-Defined Table Definition Template
_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. For more information, see ODS<=(ODS-suboptions)>.
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 in TEMPLATE Procedure: Creating Tabular Output .
@ | @@

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.
Main discussion: When the Pointer Moves Past the End of a Line

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.

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:

Variable or Expression SAS Response
Not an integer Truncates the decimal portion and uses only the integer value.
0 or negative Moves the pointer to column 1.

Default: If ods-column exceeds the number of columns in the data component, then ODS does the following:
  1. writes the current line

  2. moves the pointer to the first ODS column on the next line

  3. continues to process the PUT statement

Tip: You can alter the default behavior with options in the FILE PRINT ODS statement. For more information, see the discussion of overflow control.
Featured in: Example 4: Creating and Using a User-Defined Table Definition Template
+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.

ods-column SAS Response
A positive integer Moves the pointer to the right.
A negative integer Moves the pointer to the left.
0 Pointer does not move.

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 does the following:
  1. writes the current line

  2. moves the pointer to the first ODS column on the next line

  3. continues to process the PUT statement

See also: Example 4: Creating and Using a User-Defined Table Definition Template
@ '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 that specifies where to write.

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.

Featured in: Example 4: Creating and Using a User-Defined Table Definition Template

Note:   If you use a line pointer control to skip lines in ODS output, then SAS sets to a missing value all columns that are not referenced on the current line or skipped lines to a missing value. Columns that contain numeric values will 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 MISSING statement or the MISSING= option, see SAS Language Reference: Dictionary.  [cautionend]


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:

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.


See Also

Statement:

FILE Statement for ODS

Output Delivery System and the DATA Step

Examples

Previous Page | Next Page | Top of Page