Chapter Contents

Previous

Next
PUT, _ODS_

PUT, _ODS_



Writes data values to a special buffer from which they can be written to the data component, and formatted by ODS destinations

Valid: in a DATA step
Category: File-handling
Type: Executable


Syntax
Arguments
Options
Details
Column Pointer Controls and ODS
Line Pointer Controls
When the Pointer Goes Past the End of a Line

Syntax

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

ods-pointer-control

variable
identifies the variable to write.


Options

_ODS_
moves data values for all columns to a buffer. The order of these columns is determined by the orderthat is 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.
Interaction: You can use _ODS_ in a PUT statement that specifies the placement of individual variables. _ODS_ writes to a particular column only if a PUT statement has not already written a variable to that column. The position of _ODS_ in the PUT statement does not affect the outcome in the data component, but it may affect performance.
Restriction: Use _ODS_ only if you have previously specified the ODS option in the FILE statement.
Tip: The order of the column in the data component matches the order of the columns in buffer. However, the template that is combined with the data component to produce the output object may override this order.

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


Details

Within the DATA step, the ODS option in the FILE statement and the _ODS_ option in the PUT statement provide connections with the Output Delivery System (ODS). You use both of these connections to route the results of a DATA step to ODS. By default, when the DATA step uses ODS, ODS writes output objects to the procedure output and places links to them in the Results folder. You can use global ODS statements to write to other ODS destinations.

The FILE and PUT statements interact in the following ways:

The ODS destinations are controlled by the global ODS statements. You can use an existing template or create your own with the TEMPLATE. procedure.

For details on using the Output Delivery System, see The Complete Guide to the SAS Output Delivery System.

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

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

+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 isn't, SAS truncates the decimal portion and uses the 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, the ODS writes the current line, moves the pointer to the first column on the next line, and continues to process the PUT statement.


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 isn't, SAS truncates the decimal portion and uses the only the integer value.

/
moves the pointer to the first column of the next line.


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 the variables in the program data vector determines the number of columns.

Note:   The template 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.


Chapter Contents

Previous

Next

Top of Page

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