Concepts: Tabular Output and the TEMPLATE Procedure


Viewing the Contents of a Table Definition

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

  • Using the SAS Windowing Environment

  1. From the menu, select

    View Results.

  2. In the Results window, select the Results folder. Right-click and select Templates to open the Templates window.

  3. Double-click on SASHELP.TMPLMST to view the contents of that item store or directory.

  4. Double-click on a directory to view the list of subdirectories and table templates that you wish to view. For example, the Base SAS table definition Summary is the default template store for the summary tables created in the MEANS and SUMMARY procedures. Double-click on the Base directory, and then double-click on the Summary table.

  • Using the Command Line

    1. To view the Templates window, submit the following command:

       odstemplates 

      The Templates window contains the item stores Sasuser.Templat and Sashelp.Tmplmst .

    2. When you double-click an item store, such as Sashelp.Tmplmst , that item store expands to list the directories where ODS templates are stored. The templates that SAS provides are in the item store SASHELP.TMPLMST.

    3. To view the table definitions that SAS provides, double-click the item store that contains a table definition, such as Base .

    4. Right-click the table definition, such as Summary , and select Open . The table definition is displayed in the Template Browser window.

  • Using the TEMPLATE Procedure

    1. The SOURCE statement writes the source code for the specified definition to the SAS log. For example, if you want to view the source code for all the objects in Base SAS, submit the following code.

       proc template;  source base;  run; 

How Are Values in Table Columns 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 

If the value of JUST= D, then values are aligned by the decimal point.

 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 for JUST=R and JUST=L.

How Are Values in Table Columns Formatted?

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 do not specify a FORMAT= option, then PROC TEMPLATE uses the format that the data component provides. If the data component does not provide a format, then PROC TEMPLATE uses

    • best8. for integers

    • 12.3 for doubles

    • the length of the variable for character variables

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

  2. If you specify a decimal width with the FORMAT= and FORMAT_NDEC= options, then PROC TEMPLATE uses the format that you specified with the FORMAT= option.

  3. If you specify a format width with the FORMAT= and FORMAT_WIDTH= options, then PROC TEMPLATE uses the format that you specified with FORMAT= option.

The formatting attributes of a column can be determined by the data component or the column definition. The following table summarizes the behavior of the column formatting attributes based on which attributes the column definition provides.

Column definition provides

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 definition; number of decimal places is determined by the data component.

format name and width

format name and width are determined by the column definition.

format name, width, and number of decimal places

all three are determined by the column definition.

width

no name is specified; width is determined by the column definition; 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 definition.




SAS 9.1 Output Delivery System. Users Guide
SAS 9.1 Output Delivery System Users Guide
ISBN: 1590472187
EAN: 2147483647
Year: 2004
Pages: 99
Authors: SAS Institute

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net