Chapter Contents

Previous

Next
Using the Output Delivery System in the DATA Step

FILE Statement for ODS


Defines the structure of the data component that holds the results of the DATA step and binds that component to a table definition to produce an output object. ODS sends this object to all open ODS destinations, each of which formats the object appropriately. Also controls what happens when the PUT statement tries to write past the end of a line.

Requirements: If you use the ODS option, you must use the fileref PRINT in the FILE statement.
Restriction: The DELIMITER= and DSD options have no effect on the ODS option. The FOOTNOTES | NOFOOTNOTES, LINESIZE, PAGESIZE, and TITLES | NOTITLES options have an effect only on the listing destination. You cannot use _FILE_=, FILEVAR=, HEADER=, or PAD with the ODS option.


FILE PRINT <ODS<=(ODS-suboption(s))>><overflow-control><N=number> ;

Note:   

This syntax shows only the ODS portion of the FILE statement. For the complete syntax of the FILE statement, see SAS Language Reference: Dictionary.  [cautionend]


File Statement Arguments and Options

The arguments and options listed here can be specified in any order in the FILE statement.

N=number
specifies the number of lines that are available to the output pointer in the current iteration of the DATA step.

ODS<=(ODS-suboptions)>
Defines the structure of the data component that holds the results of the DATA step and binds that component to a table definition to produce an output object. ODS sends this object to all open ODS destinations, each of which formats the object appropriately. For information on the ODS-suboptions, see ODS Suboptions.
Default: If you do not specify any ODS suboptions, the DATA step uses a default table definition (base.datastep.table) that is stored in the SASHELP.TMPLMST template store. This definition defines two generic columns: one for character variables and one for numeric variables. ODS associates each variable in the DATA step with one of these columns and displays the variables in the order in which they are defined in the DATA step.

Without suboptions, the default table definition uses the variable's label as its column header. If no label exists, the definition uses the variable's name as the column header.

Featured in: All examples

overflow-control
determines the PUT statement behavior when the output pointer attempts to move past the last ODS column in the buffer. overflow-control is one of the following:

DROPOVER
discards items when a PUT statement attempts to write to ODS columns beyond the last ODS column in the buffer. A message in the log at the end of the DATA step informs you if data were not written to the buffer.

FLOWOVER
moves the output pointer to a new line if a PUT statement attempts to write an item to an ODS column beyond the last ODS column in the buffer. The PUT statement writes the next item in the first ODS column of the new line.

STOPOVER
stops processing the DATA step immediately if a PUT statement attempts to write to an ODS column beyond the last ODS column in the buffer. SAS discards the data item, writes the portion of the buffer that was built before the error occurred, and issues an error message.

Default: FLOWOVER

PRINT
is a reserved fileref that directs the output that is produced by any PUT statements to all open ODS destinations.
Restriction: You must use PRINT in a FILE statement that uses the ODS option.
Featured in: Using the Default Table Definition


ODS Suboptions

To do this ... Use this suboption
Specify one or more columns for the data component COLUMNS= or VARIABLES=
Specify default values for column attributes that exist in the table definition, but that get their values from the data component DYNAMIC=
Assert that all column definitions in the table definition can or cannot be used by more than one variable GENERIC=
Specify a column header to use for any column that does not have a column header specified in the COLUMNS= or VARIABLES= suboption LABEL=
Specify a name for the output object that the DATA step produces OBJECT=
Specify a label for the output object that the DATA step produces OBJECTLABEL=
Specify the table definition to use with the data component to produce the output object TEMPLATE=

COLUMNS=(column-specification(s))
specifies one or more columns for the data component. Each column-specification associates a DATA step variable with a column that is defined in the table definition. The order of the columns in the data component is determined by their order in the COLUMNS= suboption.

Note:   By default, the order of the columns in the output object is determined by their order in the table definition, not by their order in the data component. You can override this order by using the ORDER_DATA= table attribute in the PROC TEMPLATE step that creates the definition. The default DATA step table definition uses this attribute. (See the discussion of ORDER_DATA=.)  [cautionend]

Each column-specification has this general form:
column-name<=variable-name><(attribute(s))>

column-name
is the name of a column. This name must match a name that is defined in the table definition that you use.
Restriction: column-name must conform to the rules for SAS variable names. For information on these rules, see "Rules for Words and Names" in SAS Language Reference: Dictionary.
Tip: You can use list notation (for example, score1-score5) to specify multiple column names.
Featured in: Using a Simple User-Defined Definition

variable-name
specifies a variable in the DATA step to place in the specified column.
Default: If you omit variable-name, ODS looks for a DATA step variable named column-name to place in the specified column. If no such variable exists, ODS returns an error.
Tip: You can use list notation (for example, score1-score5) to specify a range of variable names.
Featured in: Using a Simple User-Defined Definition

attribute
assigns a characteristic, such as a label or a format, to a particular column in the data component. These individual specifications override any attributes that the DATA step sets. You assign attributes with the following suboptions.

DYNAMIC=dynamic-specification(s)
specifies a value for a column attribute that exists in the table definition but that get its value from the data component. For details, see the discussion of DYNAMIC=.
Featured in: Using a Simple User-Defined Definition

FORMAT=format-name
specifies a format for the current column.
Default: ODS uses the first of these formats for the variable that it finds:

  • for nongeneric columns, a format that is specified in the column definition

  • a format that is specified in the FORMAT= column attribute

  • a format that is specified in a FORMAT statement

  • the default format ($w. for character variables; BEST12. for numeric variables).

Featured in: Using a Simple User-Defined Definition

Note:   Formats for generic columns that are specified in the table definition are ignored by the DATA step interface to ODS.  [cautionend]

GENERIC=ON|OFF
specifies whether or not the DATA step uses this column definition for multiple variables. For details, see GENERIC=.
Default: OFF
Featured in: Using a Simple User-Defined Definition

LABEL='column-label'
specifies a label for this particular column. For details, see LABEL=.
Featured in: Specifying Attributes for a Column

Default: If you do not specify COLUMNS= or VARIABLES=, the order of columns in the data component matches the order of the corresponding variables in the program data vector.
Restriction: You can use only one COLUMNS= suboption in a FILE statement.
Interaction: You can use either the COLUMNS= suboption or the VARIABLES= suboption to associate variables with columns. However, you cannot use both suboptions in the same FILE statement.

DYNAMIC=(dynamic-specification(s))
specifies default values for dynamic attribute values. Columns that do not contain their own DYNAMIC= specifications use these.

A dynamic attribute value is defined in the table definition. Its name serves as a placeholder for the value that is supplied to the data component with the DYNAMIC= suboption. When ODS creates the output object from the table definition and the data component, it substitutes the appropriate value from the data component for the value's name in the table definition.

Each dynamic-specification has the following form:
dynamic-value-name<=variable-name | constant>

dynamic-value-name
is the name that the table definition gives to a dynamic attribute value (see DYNAMIC Statement).

variable-name
specifies a variable whose value is assigned to dynamic-value-name and passed to ODS to substitute for the placeholder in the table definition when it creates the output object.

constant
specifies a constant to assign to dynamic-value-name and to pass to ODS to substitute for the placeholder in the table definition when it creates the output object.

Tip: By default, DYNAMIC= applies to all columns in the data component. You can override this specification for an individual column by specifying DYNAMIC= as an attribute for that column in the COLUMNS= or the VARIABLES= suboption.

GENERIC=ON | OFF
asserts that the DATA step does or does not use all column definitions for multiple variables.

ON
asserts that the DATA step uses all column definitions for multiple variables.

OFF
asserts that the DATA step uses no column definitions for multiple variables.

Default: OFF
Interaction: If you do not specify a table definition (see TEMPLATE=), GENERIC= is set to ON.
Restriction: Unless GENERIC=ON is specified in the COLUMNS= option, in the ODS= option, and in the table definition that you are using, ODS does not recognize the column names as a match.
Tip: By default, GENERIC= applies to all columns in the data component. You can override this specification for an individual column by specifying GENERIC= as an attribute for that column in the COLUMNS= or the VARIABLES= suboption.

LABEL='column-label'
specifies a label for any column that does not have a label specified in the COLUMNS= or VARIABLES= suboption.
Default: ODS uses for the column header the first of these labels that it finds:

  • a label that is specified with HEADER= for a particular column in the table definition (see the discussion of the column attribute HEADER=).

  • a label that is specified for a particular column with LABEL= in the COLUMNS= or VARIABLES= suboption

  • a label that is specified with LABEL= in the ODS= option

  • a label that is assigned with the LABEL statement in the DATA step.

If no label is specified, the contents of the table definition determines whether the column header contains the variable name or is blank.

Featured in: Using a Simple User-Defined Definition

OBJECT=object-name
specifies a name for the output object.

The Results window and the HTML contents file both contain a description of, and a link to, each output object. The description contains the first of these items that ODS finds:

Restriction: object-name must conform to the rules for SAS variable names. For information on these rules, see "Rules for Words and Names" in SAS Language Reference: Dictionary.

OBJECTLABEL='object-label'
specifies a label for the output object.

The Results window and the HTML contents file both contain a description of and a link to each output object. The description contains the first of these items that ODS finds:

Featured in: Specifying Attributes for a Column

TEMPLATE='table-definition-name'
specifies the table definition to use with the data component to produce the output object.

table-definition-name
is the path to the table definition. SAS stores a table definition as an item in an item store. By default, ODS first looks for table-definition-name in SASUSER.TEMPLAT. If it doesn't find the definition there, it looks in SASHELP.TMPLMST. You can change the locations that it searches with the ODS PATH statement (see ODS PATH Statement).
Default: base.datastep.table
Interaction: When you use the default table definition, GENERIC= is set to ON for all columns in the data component. (See GENERIC=.)
Featured in: Using a Simple User-Defined Definition

VARIABLES=(variable-specification(s))
specifies one or more columns for the data component of the output object. Each variable-specification associates a DATA step variable with a column that is defined in the table definition.

Note:   By default, the order of the columns in the output object is determined by their order in the table definition, not by their order in the data component. You can override this order by using the ORDER_DATA table attribute in the PROC TEMPLATE step that creates the definition. The default DATA step table definition uses this attribute. (See the discussion of the ORDER_DATA=.)  [cautionend]

Each variable-specification has this general form:
variable-name<=column-name><(attribute(s))>

variable-name
specifies a variable in the DATA step to place in the specified column.
Tip: You can use list notation (for example, score1-score5) to specify a range of variable names.
Featured in: Selecting Variables for the Data Component and Specifying Attributes for a Column

column-name
is the name of a column. This name must match a name that is defined in the table definition.
Default: If you omit column-name, ODS looks for a column in the table definition that is named variable-name and places the variable in that column. If no such column exists, ODS returns an error.
Restriction: column-name must match a column name in the table definition that you are using. It must also conform to the rules for SAS variable names. For information on these rules, see "Rules for Words and Names" in SAS Language Reference: Dictionary.
Tip: You can use list notation (for example, score1-score5) to specify a range of column names.

attribute
assigns a characteristic, such as a label or a format, to a particular column in the data component. These individual specifications override any attributes that are set, in the DATA step, for the entire data component. You assign attributes just as you do in the COLUMNS= suboption (see the discussion of attributes).

Default: If you do not specify COLUMNS= or VARIABLES=, the order of columns in the data component matches the order of the corresponding variables in the program data vector.
Restriction: You can use only one VARIABLES= suboption in a FILE statement.
Interaction: You can use either the COLUMNS= suboption or the VARIABLES= suboption to associate variables with columns. However, you cannot use both suboptions in the same FILE statement.
Tip: VARIABLES= is primarily for use with the default DATA step table definition. When you are using the default definition, the DATA step can map variables to the appropriate column in the definition so you don't need to specify a column name.
Featured in: Selecting Variables for the Data Component and Specifying Attributes for a Column


Chapter Contents

Previous

Next

Top of Page

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