TEMPLATE Procedure: Creating Crosstabulation Table Templates |
Featured in: | Creating a Customized Crosstabulation Table Template with No Legend |
Task | Statement |
---|---|
Set one or more cellvalue attributes |
cellvalue-attributes |
Specify the style element of the cells in the column according to the values of the variables |
CELLSTYLE AS |
Define a symbol that references a value that the data component supplies from the procedure |
DYNAMIC |
Provide information about the crosstabulation table |
NOTES |
End a cellvalue template |
END |
Options |
specifies one of the possible values that PROC FREQ can produce for a crosstabulation table. For a cellvalue to appear in a cell, it must meet one of these requirements:
specified in a DEFINE CELLVALUE statement
included in the CELLVALUE statement
not suppressed by one of the following options for the TABLES statement in PROC FREQ: NOFREQ, NOPERCENT, NOROW, NOCOL, or CUMCOL
requested by one of the following options: EXPECTED, DEVIATION, CELLCHI2, or TOTPCT
cellvalue is one of the following:
is the frequency count.
is the expected frequency of the cell.
is the deviation of the cell frequency from the expected value.
is the cell's contribution to the total Pearson chi-square statistic.
is the percentage of total frequency on n-way tables when n>2.
is the percentage of the table frequency.
is the percentage of the row frequency.
is the percentage of the column frequency.
is the cumulative percentage of the column frequency.
DEFINE CELLVALUE Attribute Statements |
This section lists all the attribute statements that you can use in a cellvalue template and the tasks that are associated with the statements. For all attributes that support a value of ON, these forms are equivalent:
ATTRIBUTE-NAME ATTRIBUTE-NAME=ON
Task | Statement |
---|---|
Specify which format to use for the cellvalue if both a crosstabulation template and a data component specify a format |
DATA_FORMAT_OVERRIDE= |
Specify the format for the cellvalue |
FORMAT= |
Override the width specified by the FORMAT= attribute |
FORMAT_WIDTH= |
Override the number of decimals specified by the FORMAT= attribute |
FORMAT_NDEC= |
Specify the text in the legend |
HEADER= |
For the Output destination, specify the label for the data set column corresponding to the cellvalue |
LABEL= |
Specify whether a cellvalue appears in the crosstabulation table |
PRINT= |
specifies which format to use if both a crosstabulation template and a data component specify a format for Frequency, Expected, and Deviation.
selects the format specified in the data component.
selects the format specified in the crosstabulation template.
Default: | OFF |
Interaction: | If you specify DATA_FORMAT_OVERRIDE=ON, and the FORMAT option is specified on the TABLES statement in PROC FREQ, then the data component will specify that format for the Frequency, Expected, and Deviation cellvalues. |
specifies the format for the column.
Default: |
If you omit the FORMAT= option, PROC
TEMPLATE uses the format that the data component provides. If the data component
does not provide a format, PROC TEMPLATE uses one of the following:
|
Interaction: | For Listing output, the width of the cells is governed by the format width. Cells are at least one character wider than the format width. |
Range: | The minimum cell width is 8, and the maximum width is 25. |
overrides the width specified by the FORMAT= attribute statement.
See also: | FORMAT= |
overrides the number of decimals specified by the FORMAT= attribute statement.
See also: | FORMAT= |
specifies the text in the legend.
Tip: | For Listing output, only the first 15 characters of text are displayed. |
for the Output destination, specifies the label for the data set column that corresponds to the cellvalue.
specifies whether the cellvalue appears in the crosstabulation table.
Both this attribute and the TABLES statement option for the cellvalue control the presence of the cellvalue in the table. For example, the expected cell frequency is present only when the EXPECTED option is used and the Expected cellvalue template has PRINT=ON specified.
CELLSTYLE AS Statement |
Featured in: | Creating a Customized Crosstabulation Table Template with No Legend |
CELLSTYLE expression-1 AS <style-element-name><[style-attribute-specification(s)] ><..., expression-n AS <style-element-name><[style-attribute-specification(s)]>>; |
Required Arguments |
is an expression that is evaluated for each cell. If expression resolves to TRUE (a non-zero value), the style element that is specified is used for the current cell. If expression is FALSE (zero), the next expression in the statement is evaluated. Thus, you can string multiple expressions together to format cells conditionally.
expression has this form:
expression-1 <comparison-operator expression-n> |
is an arithmetic or logical expression that consists of a sequence of operators and operands. An operator is a symbol that requests a comparison, logical operation, or arithmetic calculation. An operand is one of the following:
is a fixed value that you can use to set a constant style element.
Example: |
These statements set the cellvalue Frequency
background to gray:
define cellvalue Frequency; other-statements ...; cellstyle 1 as {backgroundcolor=gray}; end; |
is the value of the current cell.
Example: |
The following statements change the
foreground color of the cellvalue Percent depending on its magnitude:
define cellvalue Percent; other-statements ...; cellstyle _val_ > 75.00 as {color=red}, _val_ > 50.00 as {color=orange}, _val_ > 25.00 as {color=green}; end; |
compares a variable with a value or with another variable.
Symbol | Mnemonic Equivalent | Definition |
---|---|---|
= | EQ | Equal to |
^= or ~= or ¬= or <> | NE | Not equal to |
> | GT | Greater than |
< | LT | Less than |
>= | GE | Greater than or equal to |
<= | LE | Less than or equal to |
|
IN | Equal to one from a list of values |
Tip: | Using an expression of 1 as the last expression in the CELLSTYLE AS statement sets the style element for any cells that did not meet an earlier condition. |
Options |
Note: Neither style-attribute-specification nor style-element-name is required. However, you must use at least one of them.
describes a style attribute to set. Each style-attribute-specification has this general form:
style-attribute-name=style-attribute-value |
Default: | If you do not specify any style attributes to modify, ODS uses the unmodified style-element-name. |
is the name of the style element that displays the data in the column. The style element must be part of a style that is registered with the Output Delivery System. SAS provides some styles. You can create customized styles by using PROC TEMPLATE (see DEFINE STYLE Statement). By default, ODS displays different parts of ODS output with different style elements. For example, by default, the data in a column is displayed with the style element Data. The style elements that you would probably use with the CELLSTYLE AS statement in a column template are the following.
Data
DataFixed
DataEmpty
DataEmphasis
DataEmphasisFixed
DataStrong
DataStrongFixed
The style element provides the basis for displaying the column. Additional style attributes that you provide can modify the display.
Default: | Data |
See also: | Viewing the Contents of a Style |
See also: | Working with Styles |
DYNAMIC Statement |
Tip: | A dynamic variable that is defined in a template is available to that template and all the templates that it contains. |
DYNAMIC dynamic-variable(s) ; |
Required Arguments |
is a variable that is defined by SAS in the crosstabulation template. After a dynamic variable has been defined, you can use it in the TEXT statement within a footer or header template.
is the number of missing values in the table.
Requirement: | The FMISSING dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression. |
is set to 1 if the PROC FREQ's NOTITLE option was used, and it is set to 0 if the NOTITLE option was not used.
Requirement: | The NOTITLE dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression. |
is set to 0 if the table is empty. Otherwise, it is set to 1.
Requirement: | The SAMPLESIZE dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression. |
is the current stratum number if the table has multiple strata. If the table has only one stratum, then the value is 0.
Requirement: | The STRATNUM dynamic variable must be specified by the DYNAMIC statement before you can use the dynamic variable in an expression. |
Featured in: | Creating a Customized Crosstabulation Table Template with No Legend |
is a string that identifies the current stratum by the name of the stratum variables.
var-1=value-1<var-n=value-n> |
specifies the stratum variables.
specifies the values of the stratum variables.
Tip: | The value is undefined if the table has only one stratum. |
Requirement: | The DYNAMIC statement must specify the STRATAVARIABLELABELS dynamic variables before the dynamic variables can be used in an expression. |
is a string that identifies the current stratum by the label of the stratum variables.
var-1=value-1<var-n=value-n> |
specifies the stratum variables.
specifies the values of the stratum variables.
Tip: | The value is undefined when the table has only one stratum. |
Requirement: | The DYNAMIC statement must specify the STRATAVARIABLELABELS dynamic variables before you can use the dynamic variables in an expression. |
Featured in: | Creating a Customized Crosstabulation Table Template with No Legend and Creating a Crosstabulation Table Template with a Customized Legend |
NOTES Statement |
Tip: | The NOTES statement becomes part of the compiled template, which you can view with the SOURCE statement. SAS comments do not become part of the template. |
NOTES 'text'; |
Required Arguments |
provides information about the template.
END Statement |
END; |
Copyright © 2008 by SAS Institute Inc., Cary, NC, USA. All rights reserved.