Chapter Contents

Previous

Next
Using the Output Delivery System in the DATA Step

_ODS_ in the PUT Statement


PUT <specification(s)><_ODS_><@|@@>;


Arguments

specification
specifies the variables to write and where to write them. Each specification has the following form:
<ods-pointer-control>variable

variable
identifies the variable to write.
Featured in: Using a Simple User-Defined Definition

ods-pointer-control
moves the pointer in the buffer to a specified line or column.
See also: Column Pointer Controls and ODS and Line Pointer Controls


Options

_ODS_
moves data values for all columns to a buffer. The order of these columns is determined by the order specified by the COLUMNS= or VARIABLES= suboption in the ODS option in the FILE statement. If you do not specify either of these options, the order of the variables in the program data vector determines their order in the buffer.

The PUT statement writes this buffer to the data component.
Restriction: Use _ODS_ only if you have previously specified the ODS option in the FILE statement. (See FILE Statement for ODS.)
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, but it may affect performance.
Tip: The order of the columns in the data component matches the order of the columns in buffer. However, the table definition that is combined with the data component to produce the output object may override this order. (See the discussion of the ORDER_DATA= table attribute.)

@ | @@
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 @@, each PUT statement in a DATA step writes a new line to the buffer.


Column Pointer Controls and ODS

Column pointer controls in a DATA step that uses ODS differ slightly from column pointer controls in a DATA step that does not use ODS. ODS is not character-based. Therefore, in ODS a column contains the entire value of a variable. Column 1 contains the first variable in the output; column 2 contains the second variable, and so on.

Column pointer controls have the following general forms:
@ods-column
+ods-column
@'column-name'

@ods-column
moves the pointer to the specified ODS column. ods-column can be a number, a numeric-variable, or an expression that identifies the column to write to.
Range: If ods-column is a number, it must be a positive integer.

If ods-column is a variable or an expression, SAS treats it as follows:

If the variable or expression is ... SAS does this
not an integer truncates the decimal portion and uses only the integer value
0 or negative moves the pointer to column 1

Tip: By default, if ods-column exceeds the number of columns in the data component, ODS writes the current line, moves the pointer to the first column on the next line, and continues to process the PUT statement. You can alter this behavior with options in the FILE statement. (See the discussion of overflow-control.)
Featured in: Using a Simple User-Defined Definition

+ods-column
moves the pointer the specified number of columns. ods-column can be a number, a numeric-variable, or an expression that specifies the number of columns to move the pointer.
Range: If ods-column is a number, it must be an integer. If ods-column is a variable or an expression, it does not have to be an integer. If it is not an integer, SAS truncates the decimal portion and uses only the integer value.
Tip: If ods-column is greater than 0, the pointer moves to the right. If ods-column is less than 0, the pointer moves to the left. If ods-column is equal to 0, the pointer does not move.

If the current column position becomes less than 1, the pointer moves to column 1. If the current column position exceeds the number of columns in the data component, ODS writes the current line, moves the pointer to the first column on the next line, and continues to process the PUT statement.

See also: When the Pointer Goes Past the End of a Line

@'column-name'
moves the pointer to the ODS column identified by 'column-name'.


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. Line pointer controls have the following general forms:
#line
/

#line
moves the pointer to the specified line. line can be a number, a numeric-variable, or an expression that identifies the line to write to.
Range: If line is a number, it must be an integer. If line is a variable or an expression, it does not have to be an integer. If it is not an integer, SAS truncates the decimal portion and uses only the integer value.

/
moves the pointer to the first column of the next line.
Featured in: Using a Simple User-Defined Definition


When the Pointer Goes Past the End of a Line

In a DATA step that uses the Output Delivery System, the number of columns that is specified by the COLUMNS= or VARIABLES= suboption to the ODS option in the FILE statement determines the number of columns in the buffer and, eventually, in the data component. If you do not specify either of these options, the number of variables in the program data vector determines the number of columns.

Note:   The table definition that is combined with the data component to produce the output object may change the number of columns that actually appear in the output object.  [cautionend]

Using pointer controls and trailing @ or double trailing @, you may inadvertently position the pointer beyond the last column. You control how SAS handles this situation with options in the FILE statement. (See the discussion of overflow-control.)


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.