Previous Page | Next Page

TEMPLATE Procedure: Creating Tabular Output

Concepts: Tabular Output and the TEMPLATE Procedure


Viewing the Contents of a Table Template

To view the contents of a table template, use the SAS windowing environment, the command line, or the TEMPLATE procedure.


Values in Table Columns and How They Are Justified

The process of justifying the values in columns in a listing output is determined by the format of the variable and the values of two attributes: JUST= and JUSTIFY=. It is a three-step process:

  1. ODS puts the value into the format for the column. Character variables are left-justified within their format fields; numeric variables are right-justified.

  2. ODS justifies the entire format field within the column width according to the value of the JUST= attribute for the column, or, if that attribute is not set, JUST= for the table. For example, if you right-justify the column, the format field is placed as far to the right as possible. However, the placement of the individual numbers and characters within the field does not change. Thus, decimal points remain aligned. If the column and the format field have the same width, then JUST= has no apparent effect because the format field occupies the entire column.

  3. If you specify JUSTIFY=ON for the column or the table, ODS justifies the values within the column without regard to the format field. By default, JUSTIFY=OFF.

For example, consider this set of values:

123.45
234.5
.
987.654

If the values are formatted with a 6.2 format and displayed in a column with a width of 6, they appear this way, regardless of the value of JUST= (asterisks indicate the width of the column):

******
123.45
234.50
   .
987.65

If the width of the column increases to 8, then the value of JUST= does affect the placement of the values, because the format field has room to move within the column. Notice that the decimal points remain aligned but that the numbers shift in relation to the column width.

just=left                 just=center                 just=right

********                  ********                    ********
123.45                     123.45                       123.45
234.50                     234.50                       234.50
   .                          .                            .
987.65                     987.65                       987.65

Now, if you add JUSTIFY=ON, then the values are formatted within the column without regard to the format width. The results are as follows:

justify=on                justify=on                  justify=on
just=left                 just=center                 just=right

********                  ********                    ********
123.45                     123.45                       123.45
234.50                     234.50                       234.50
.                            .                               .
987.65                     987.65                       987.65

All destinations except LISTING justify the values in columns as if JUSTIFY=ON.


Formatting Values in Table Columns

The process of formatting the values in columns in a listing output is determined by the format of the variable and the values of three options: FORMAT=, FORMAT_WIDTH=, and FORMAT_NDEC=. It is a four-step process:

  1. If you omit a FORMAT= option, then the format that the data component provides is used. If the data component does not provide a format, then ODS uses one of the following:

    • best8. for integers

    • D12.3 for doubles

    • the length of the variable for character variables

  2. If a format width is specified in the FORMAT= option, then it will take precedence over the FORMAT_WIDTH= and FORMAT_NDEC= options.

  3. If you specify a decimal width with the FORMAT= and FORMAT_NDEC= options, then the format that is specified with the FORMAT= option is used.

  4. If you specify a format width with the FORMAT= and FORMAT_WIDTH= options, then the format that is specified with FORMAT= option is used.

The formatting attributes of a column is determined by the data component or the column template. This table summarizes the behavior of the column formatting attributes based on which attributes the column template provides.

Summary of Column Formatting Attributes
Specifications Provided by the Column Template Result
Nothing Format name, width, and number of decimal places are determined by the data component.
Format name Format name and width are determined by the column template; number of decimal places is determined by the data component.
Format name and width Format name and width are determined by the column template.
Format name, width, and number of decimal places All three are determined by the column template.
Width No name is specified; width is determined by the column template; number of decimal places is determined by the data component.
Number of decimal places No name is specified; width is determined by the data component; number of decimal places is determined by the column template.

Previous Page | Next Page | Top of Page