Requirements: At least one TABLE statement is required.
Requirements: Depending on the variables that appear in the TABLE statement, a CLASS statement, a VAR statement, or both are required.
Tip: Supports the Output Delivery System. See Output Delivery System on page 32 for details.
ODS Table Name : Table
Reminder: You can use the ATTRIB, FORMAT, LABEL, and WHERE statements. See Chapter 3, Statements with the Same Function in Multiple Procedures, on page 57 for details. You can also use any global statements. See Global Statements on page 18 for a list.
PROC TABULATE < option(s) >;
BY <DESCENDING> variable-1
< <DESCENDING> variable-n >
<NOTSORTED>;
CLASS variable(s) </ options >;
CLASSLEV variable(s) / STYLE =< style-element-name PARENT>
<[ style-attribute-specification(s) ]>;
FREQ variable ;
KEYLABEL keyword-1= description-1
< keyword-n= description-n >;
KEYWORD keyword(s) / STYLE =< style-element-name PARENT>
<[ style-attribute-specification(s) ]>;
TABLE << page-expression ,> row-expression ,> column-expression </ table-option(s) >;
VAR analysis-variable(s) </ options >;
WEIGHT variable ;
To do this | Use this statement |
---|---|
Create a separate table for each BY group | BY |
Identify variables in the input data set as class variables | CLASS |
Specify a style for class variable level value headings | CLASSLEV |
Identify a variable in the input data set whose values represent the frequency of each observation | FREQ |
Specify a label for a keyword | KEYLABEL |
Specify a style for keyword headings | KEYWORD |
Describe the table to create | TABLE |
Identify variables in the input data set as analysis variables | VAR |
Identify a variable in the input data set whose values weight each observation in the statistical calculations | WEIGHT |
PROC TABULATE < option(s) >;
To do this | Use this option | |
---|---|---|
Customize the HTML contents link to the output | CONTENTS= | |
Specify the input data set | DATA= | |
Specify the output data set | OUT= | |
Override the SAS system option THREADS NOTHREADS | THREADS NOTHREADS | |
Enable floating point exception recovery | TRAP | |
Identify categories of data that are of interest | ||
Specify a secondary data set that contains the combinations of values of class variables to include in tables and output data sets | CLASSDATA= | |
Exclude from tables and output data sets all combinations of class variable values that are not in the CLASSDATA= data set | EXCLUSIVE | |
Consider missing values as valid values for class variables | MISSING | |
Control the statistical analysis | ||
Specify the confidence level for the confidence limits | ALPHA= | |
Exclude observations with nonpositive weights | EXCLNPWGTS | |
Specify the sample size to use for the P 2 quantile estimation method | QMARKERS= | |
Specify the quantile estimation method | QMETHOD= | |
Specify the mathematical definition to calculate quantiles | QNTLDEF= | |
Specify the variance divisor | VARDEF= | |
Customize the appearance of the table | ||
Specify a default format for each cell in the table | FORMAT= | |
Define the characters to use to construct the table outlines and dividers | FORMCHAR= | |
Eliminate horizontal separator lines from the row titles and the body of the table | NOSEPS | |
Order the values of a class variable according to the specified order | ORDER= | |
Specify the default style element or style elements (for the Output Delivery System) to use for each cell of the table | STYLE= |
ALPHA= value
specifies the confidence level to compute the confidence limits for the mean. The percentage for the confidence limits is (1 “ value ) 100. For example, ALPHA=.05 results in a 95% confidence limit.
Default: .05
Range: between 0 and 1
Interaction: To compute confidence limits specify the statistic-keyword LCLM or UCLM.
CLASSDATA= SAS-data-set
specifies a data set that contains the combinations of values of the class variables that must be present in the output. Any combinations of values of the class variables that occur in the CLASSDATA= data set but not in the input data set appear in each table or output data set and have a frequency of zero.
Restriction: The CLASSDATA= data set must contain all class variables. Their data type and format must match the corresponding class variables in the input data set.
Interaction: If you use the EXCLUSIVE option, then PROC TABULATE excludes any observations in the input data set whose combinations of values of class variables are not in the CLASSDATA= data set.
Tip: Use the CLASSDATA= data set to filter or supplement the input data set.
Featured in: Example 2 on page 1249
CONTENTS= link-name
enables you to name the link in the HTML table of contents that points to the ODS output of the first table that was produced by using the TABULATE procedure.
Note: CONTENTS= affects only the contents file of ODS HTML output. It has no effect on the actual TABULATE procedure reports .
DATA= SAS-data-set
specifies the input data set.
Main Discussion: Input Data Sets on page 19
EXCLNPWGTS
excludes observations with nonpositive weight values (zero or negative) from the analysis. By default, PROC TABULATE treats observations with negative weights like those with zero weights and counts them in the total number of observations.
Alias: EXCLNPWGT
See also: WEIGHT= on page 1226 and WEIGHT Statement on page 1226
EXCLUSIVE
excludes from the tables and the output data sets all combinations of the class variable that are not found in the CLASSDATA= data set.
Requirement: If a CLASSDATA= data set is not specified, then this option is ignored.
Featured in: Example 2 on page 1249
FORMAT= format-name
specifies a default format for the value in each table cell. You can use any SAS or user -defined format.
Alias: F=
Default: If you omit FORMAT=, then PROC TABULATE uses BEST12.2 as the default format.
Interaction: Formats that are specified in a TABLE statement override the format that is specified with FORMAT=.
Tip: This option is especially useful for controlling the number of print positions that are used to print a table.
Featured in: Example 1 on page 1246 and Example 6 on page 1260
FORMCHAR <( position(s) )>= formatting-character(s)
defines the characters to use for constructing the table outlines and dividers.
position(s)
identifies the position of one or more characters in the SAS formatting-character string. A space or a comma separates the positions.
Default: Omitting position(s) is the same as specifying all 20 possible SAS formatting characters, in order.
Range: PROC TABULATE uses 11 of the 20 formatting characters that SAS provides. Table 48.2 on page 1204 shows the formatting characters that PROC TABULATE uses. Figure 48.3 on page 1205 illustrates the use of each formatting character in the output from PROC TABULATE.
Position | Default | Used to draw |
---|---|---|
1 |
| the right and left borders and the vertical separators between columns |
2 | - | the top and bottom borders and the horizontal separators between rows |
3 | - | the top character in the left border |
4 | - | the top character in a line of characters that separate columns |
5 | - | the top character in the right border |
6 |
| the leftmost character in a row of horizontal separators |
7 | + | the intersection of a column of vertical characters and a row of horizontal characters |
8 |
| the rightmost character in a row of horizontal separators |
9 | - | the bottom character in the left border |
10 | - | the bottom character in a line of characters that separate columns |
11 | - | the bottom character in the right border |
Figure 48.3: Formatting Characters in PROC TABULATE Output
formatting-character(s)
lists the characters to use for the specified positions. PROC TABULATE assigns characters in formatting-character(s) to position(s) , in the order that they are listed. For example, the following option assigns the asterisk (*) to the third formatting character, the pound sign (#) to the seventh character, and does not alter the remaining characters:
formchar(3,7)='*#'
Interaction: The SAS system option FORMCHAR= specifies the default formatting characters. The system option defines the entire string of formatting characters. The FORMCHAR= option in a procedure can redefine selected characters.
Restriction: The FORMCHAR= option affects only the traditional SAS monospace output destination.
Tip: You can use any character in formatting-characters , including hexadecimal characters. If you use hexadecimal characters, then you must put an x after the closing quotation mark. For instance, the following option assigns the hexadecimal character 2D to the third formatting character, assigns the hexadecimal character 7C to the seventh character, and does not alter the remaining characters:
formchar(3,7)='2D7C'x
Tip: Specifying all blanks for formatting-character(s) produces tables with no outlines or dividers.
formchar(1,2,3,4,5,6,7,8,9,10,11) =' ' (11 blanks)
See also: For more information about formatting output, see Chapter 5, Controlling the Table s Appearance, in the SAS Guide to TABULATE Processing .
For information about which hexadecimal codes to use for which characters, consult the documentation for your hardware.
MISSING
considers missing values as valid values to create the combinations of class variables. Special missing values that are used to represent numeric values (the letters A through Z and the underscore (_) character) are each considered as a separate value.
A heading for each missing value appears in the table.
Default: If you omit MISSING, then PROC TABULATE does not include observations with a missing value for any class variable in the report.
Main Discussion: Including Observations with Missing Class Variables on page 1239
See also: SAS Language Reference: Concepts for a discussion of missing values that have special meaning.
NOSEPS
eliminates horizontal separator lines from the row titles and the body of the table. Horizontal separator lines remain between nested column headers.
Restriction: The NOSEPS option affects only the traditional SAS monospace output destination.
Tip: If you want to replace the separator lines with blanks rather than remove them, then use the FORMCHAR= option on page 1203.
Featured in: Example 8 on page 1265
NOTHREADS
See THREADS NOTHREADS on page 1209.
NOTRAP
See TRAP NOTRAP on page 1209.
ORDER=DATA FORMATTED FREQ UNFORMATTED
specifies the sort order to create the unique combinations of the values of the class variables, which form the headings of the table, according to the specified order.
DATA
orders values according to their order in the input data set.
Interaction: If you use PRELOADFMT in the CLASS statement, then the order for the values of each class variable matches the order that PROC FORMAT uses to store the values of the associated user-defined format. If you use the CLASSDATA= option, then PROC TABULATE uses the order of the unique values of each class variable in the CLASSDATA= data set to order the output levels. If you use both options, then PROC TABULATE first uses the user-defined formats to order the output. If you omit EXCLUSIVE, then PROC TABULATE appends after the user-defined format and the CLASSDATA= values the unique values of the class variables in the input data set in the same order in which they are encountered .
Tip: By default, PROC FORMAT stores a format definition in sorted order. Use the NOTSORTED option to store the values or ranges of a user defined format in the order that you define them.
FORMATTED
orders values by their ascending formatted values. If no format has been assigned to a numeric class variable, then the default format, BEST12., is used. This order depends on your operating environment.
Alias: FMT EXTERNAL
FREQ
orders values by descending frequency count.
Interaction: Use the ASCENDING option in the CLASS statement to order values by ascending frequency count.
UNFORMATTED
orders values by their unformatted values, which yields the same order as PROC SORT. This order depends on your operating environment. This sort sequence is particularly useful for displaying dates chronologically.
Alias: UNFMT INTERNAL
Default: UNFORMATTED
Interaction: If you use the PRELOADFMT option in the CLASS statement, then PROC TABULATE orders the levels by the order of the values in the user-defined format.
Featured in: Understanding the Order of Headings with ORDER=DATA on page 1244
OUT= SAS-data-set
names the output data set. If SAS-data-set does not exist, then PROC TABULATE creates it.
The number of observations in the output data set depends on the number of categories of data that are used in the tables and the number of subtables that are generated. The output data set contains these variables (in this order):
by variables
variables that are listed in the BY statement.
class variables
variables that are listed in the CLASS statement.
_TYPE_
a character variable that shows which combination of class variables produced the summary statistics in that observation. Each position in _TYPE_ represents one variable in the CLASS statement. If that variable is in the category that produced the statistic, then the position contains a 1; if it is not, then the position contains a 0. In simple PROC TABULATE steps that do not use the universal class variable ALL, all values of _TYPE_ contain only 1 s because the only categories that are being considered involve all class variables. If you use the variable ALL, then your tables will contain data for categories that do not include all the class variables, and positions of _TYPE_ will, therefore, include both 1 s and 0 s.
_PAGE_
The logical page that contains the observation.
_TABLE_
The number of the table that contains the observation.
statistics
statistics that are calculated for each observation in the data set.
Featured in: Example 3 on page 1251
PCTLDEF=
See QNTLDEF= on page 1207.
QMARKERS= number
specifies the default number of markers to use for the P 2 quantile estimation method. The number of markers controls the size of fixed memory space.
Default: The default value depends on which quantiles you request. For the median (P50), number is 7. For the quartiles (P25 and P75), number is 25. For the quantiles P1, P5, P10, P90, P95, or P99, number is 105. If you request several quantiles, then PROC TABULATE uses the largest default value of number .
Range: an odd integer greater than 3
Tip: Increase the number of markers above the default settings to improve the accuracy of the estimates; reduce the number of markers to conserve memory and computing time.
Main Discussion: Quantiles on page 555
QMETHOD=OSP2HIST
specifies the method PROC TABULATE uses to process the input data when it computes quantiles. If the number of observations is less than or equal to the QMARKERS= value and QNTLDEF=5, then both methods produce the same results.
OS
uses order statistics. This is the technique that PROC UNIVARIATE uses.
Note: This technique can be very memory- intensive .
P2HIST
uses the P 2 method to approximate the quantile.
Default: OS
Restriction: When QMETHOD=P2, PROC TABULATE does not compute weighted quantiles.
Tip: When QMETHOD=P2, reliable estimates of some quantiles (P1, P5, P95, P99) may not be possible for some types of data.
Main Discussion: Quantiles on page 555
QNTLDEF=12345
specifies the mathematical definition that the procedure uses to calculate quantiles when QMETHOD=OS is specified. When QMETHOD=P2, you must use QNTLDEF=5.
Default: 5
Alias: PCTLDEF=
Main discussion: Quantile and Related Statistics on page 1359
STYLE=< style-element-name PARENT>[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]
specifies the style element to use for the data cells of a table when it is used in the PROC TABULATE statement. For example, the following statement specifies that the background color for data cells be red:
proc tabulate data=one style=[background=red];
Note: This option can be used in other statements, or in dimension expressions, to specify style elements for other parts of a table.
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
style-element-name
is the name of a style element that is part of a style definition that is registered with the Output Delivery System. SAS provides some style definitions. You can create your own style definitions with PROC TEMPLATE.
Default: If you do not specify a style element, then PROC TABULATE uses Data.
See also: See The Complete Guide to the SAS Output Delivery System for information about PROC TEMPLATE and the default style definitions.
PARENT
specifies that the data cell use the style element of its parent heading. The parent style element of a data cell is one of the following:
the style element of the leaf heading above the column that contains the data cell, if the table specifies no row dimension, or if the table specifies the style element in the column dimension expression.
the style element of the leaf heading above the row that contains the cell, if the table specifies the style element in the row dimension expression.
the Beforecaption style element, if the table specifies the style element in the page dimension expression.
undefined , otherwise .
Note: The parent of a heading (not applicable to STYLE= in the PROC TABULATE statement) is the heading under which the current heading is nested.
style-attribute-name
specifies the attribute to change. The following table shows attributes that you can set or change with the STYLE= option in the PROC TABULATE statement (or in any other statement that uses STYLE=, except for the TABLE statement). Note that not all attributes are valid in all destinations.
ASIS= | FONT_WIDTH= |
BACKGROUND= | HREFTARGET= |
BACKGROUNDIMAGE= | HTMLCLASS= |
BORDERCOLOR= | JUST= |
BORDERCOLORDARK= | NOBREAKSPACE= |
BORDERCOLORLIGHT= | POSTHTML= |
BORDERWIDTH= | POSTIMAGE= |
CELLHEIGHT= | POSTTEXT= |
CELLWIDTH= | PREHTML= |
FLYOVER= | PREIMAGE= |
FONT= | PRETEXT= |
FONT_FACE= | PROTECTSPECIALCHARS= |
FONT_SIZE= | TAGATTR= |
FONT_STYLE= | URL= |
FONT_WEIGHT= | VJUST= |
style-attribute-value
specifies a value for the attribute. Each attribute has a different set of valid values. See The Complete Guide to the SAS Output Delivery System for more information about these style attributes, their valid values, and their applicable destinations.
Alias: S=
Restriction: This option affects only the HTML, RTF, and Printer destinations.
Tip: To specify a style element for data cells with missing values, use STYLE= in the TABLE statement MISSTEXT= option.
See also: Using Style Elements in PROC TABULATE on page 1234
Featured in: Example 14 on page 1293
THREADS NOTHREADS
enables or disables parallel processing of the input data set. This option overrides the SAS system option THREADS NOTHREADS. See SAS Language Reference: Concepts for more information about parallel processing.
Default: value of SAS system option THREADS NOTHREADS.
Interaction: PROC TABULATE uses the value of the SAS system option THREADS except when a BY statement is specified or the value of the SAS system option CPUCOUNT is equal to 1. In those cases, you can use THREADS in the PROC TABULATE statement to force PROC TABULATE to use parallel processing.
TRAP NOTRAP
enables or disables floating point exception (FPE) recovery during data processing beyond that provided by normal SAS FPE handling, which terminates PROC TABULATE in the case of math exceptions. Note that with NOTRAP, normal SAS FPE handling is still in effect so that PROC TABULATE terminates in the case of math exceptions.
Default: NOTRAP
VARDEF= divisor
specifies the divisor to use in the calculation of the variance and standard deviation. Table 48.3 on page 1209 shows the possible values for divisor and the associated divisors.
Value | Divisor | Formula for Divisor |
---|---|---|
DF | degrees of freedom | n ˆ’ 1 |
N | number of observations | n |
WDF | sum of weights minus one | ( i w i ) ˆ’ 1 |
WEIGHT WGT | sum of weights | i w i |
The procedure computes the variance as CSS/divisor , where CSS is the corrected sums of squares and equals . When you weight the analysis variables, CSS equals where x w is the weighted mean.
Default: DF
Requirement: To compute standard error of the mean, use the default value of VARDEF=.
Tip: When you use the WEIGHT statement and VARDEF=DF, the variance is an estimate of ƒ 2 , where the variance of the i th observation is var ( x i ) = ƒ 2 / w i , and w i is the weight for the i th observation. This yields an estimate of the variance of an observation with unit weight.
Tip: When you use the WEIGHT statement and VARDEF=WGT, the computed variance is asymptotically (for large n ) an estimate of , where w is the average weight. This yields an asymptotic estimate of the variance of an observation with average weight.
See also: Weighted Statistics Example on page 65
Creates a separate table on a separate page for each BY group.
Main discussion: BY on page 58
BY <DESCENDING> variable-1
< <DESCENDING> variable-n >
<NOTSORTED>;
variable
specifies the variable that the procedure uses to form BY groups. You can specify more than one variable. If you do not use the NOTSORTED option in the BY statement, then the observations in the data set must either be sorted by all the variables that you specify, or they must be indexed appropriately. Variables in a BY statement are called BY variables .
DESCENDING
specifies that the observations are sorted in descending order by the variable that immediately follows the word DESCENDING in the BY statement.
NOTSORTED
specifies that observations are not necessarily sorted in alphabetic or numeric order. The observations are grouped in another way, for example, chronological order.
The requirement for ordering or indexing observations according to the values of BY variables is suspended for BY-group processing when you use the NOTSORTED option. In fact, the procedure does not use an index if you specify NOTSORTED. The procedure defines a BY group as a set of contiguous observations that have the same values for all BY variables. If observations with the same values for the BY variables are not contiguous, then the procedure treats each contiguous set as a separate BY group.
Identifies class variables for the table. Class variables determine the categories that PROC TABULATE uses to calculate statistics.
Tip: You can use multiple CLASS statements.
Tip: Some CLASS statement options are also available in the PROC TABULATE statement. They affect all CLASS variables rather than just the one(s) that you specify in a CLASS statement.
CLASS variable(s) </ option(s) >;
variable(s)
specifies one or more variables that the procedure uses to group the data. Variables in a CLASS statement are referred to as class variables . Class variables can be numeric or character. Class variables can have continuous values, but they typically have a few discrete values that define the classifications of the variable. You do not have to sort the data by class variables.
ASCENDING
specifies to sort the class variable values in ascending order.
Alias: ASCEND
Interaction: PROC TABULATE issues a warning message if you specify both ASCENDING and DESCENDING and ignores both options.
DESCENDING
specifies to sort the class variable values in descending order.
Alias: DESCEND
Default: ASCENDING
Interaction: PROC TABULATE issues a warning message if you specify both ASCENDING and DESCENDING and ignores both options.
EXCLUSIVE
excludes from tables and output data sets all combinations of class variables that are not found in the preloaded range of user-defined formats.
Requirement: You must specify the PRELOADFMT option in the CLASS statement to preload the class variable formats.
Featured in: Example 3 on page 1251
GROUPINTERNAL
specifies not to apply formats to the class variables when PROC TABULATE groups the values to create combinations of class variables.
Interaction: If you specify the PRELOADFMT option in the CLASS statement, then PROC TABULATE ignores the GROUPINTERNAL option and uses the formatted values.
Interaction: If you specify the ORDER=FORMATTED option, then PROC TABULATE ignores the GROUPINTERNAL option and uses the formatted values.
Tip: This option saves computer resources when the class variables contain discrete numeric values.
MISSING
considers missing values as valid class variable levels. Special missing values that represent numeric values (the letters A through Z and the underscore (_) character) are each considered as a separate value.
Default: If you omit MISSING, then PROC TABULATE excludes the observations with any missing CLASS variable values from tables and output data sets.
See also: SAS Language Reference: Concepts for a discussion of missing values with special meanings.
MLF
enables PROC TABULATE to use the format label or labels for a given range or overlapping ranges to create subgroup combinations when a multilabel format is assigned to a class variable.
Requirement: You must use PROC FORMAT and the MULTILABEL option in the VALUE statement to create a multilabel format.
Interaction: Using MLF with ORDER=FREQ may not produce the order that you expect for the formatted values.
Interaction: When you specify MLF, the formatted values of the class variable become internal values. Therefore, specifying ORDER=FORMATTED produces the same results as specifying ORDER=UNFORMATTED.
Tip: If you omit MLF, then PROC TABULATE uses the primary format labels, which correspond to the first external format value, to determine the subgroup combinations.
See also: The MULTILABEL option on page 449 in the VALUE statement of the FORMAT procedure.
Featured in: Example 4 on page 1256
Note: When the formatted values overlap, one internal class variable value maps to more than one class variable subgroup combination. Therefore, the sum of the N statistics for all subgroups is greater than the number of observations in the data set (the overall N statistic).
ORDER=DATA FORMATTED FREQ UNFORMATTED
specifies the order to group the levels of the class variables in the output, where
DATA
orders values according to their order in the input data set.
Interaction: If you use PRELOADFMT, then the order for the values of each class variable matches the order that PROC FORMAT uses to store the values of the associated user-defined format. If you use the CLASSDATA= option in the PROC statement, then PROC TABULATE uses the order of the unique values of each class variable in the CLASSDATA= data set to order the output levels. If you use both options, then PROC TABULATE first uses the user-defined formats to order the output. If you omit EXCLUSIVE in the PROC statement, then PROC TABULATE places, in the order in which they are encountered, the unique values of the class variables that are in the input data set after the user-defined format and the CLASSDATA= values.
Tip: By default, PROC FORMAT stores a format definition in sorted order. Use the NOTSORTED option to store the values or ranges of a user-defined format in the order that you define them.
FORMATTED
orders values by their ascending formatted values. This order depends on your operating environment.
Alias: FMT EXTERNAL
FREQ
orders values by descending frequency count.
Interaction: Use the ASCENDING option to order values by ascending frequency count.
UNFORMATTED
orders values by their unformatted values, which yields the same order as PROC SORT. This order depends on your operating environment. This sort sequence is particularly useful for displaying dates chronologically.
Alias: UNFMT INTERNAL
Default: UNFORMATTED
Interaction: If you use the PRELOADFMT option in the CLASS statement, then PROC TABULATE orders the levels by the order of the values in the user-defined format.
Tip: By default, all orders except FREQ are ascending. For descending orders, use the DESCENDING option.
Featured in: Understanding the Order of Headings with ORDER=DATA on page 1244
PRELOADFMT
specifies that all formats are preloaded for the class variables.
Requirement: PRELOADFMT has no effect unless you specify EXCLUSIVE, ORDER=DATA, or PRINTMISS and you assign formats to the class variables.
Note: If you specify PRELOADFMT without also specifying EXCLUSIVE, ORDER=DATA, or PRINTMISS, then SAS writes a warning message to the SAS log.
Interaction: To limit PROC TABULATE output to the combinations of formatted class variable values present in the input data set, use the EXCLUSIVE option in the CLASS statement.
Interaction: To include all ranges and values of the user-defined formats in the output, use the PRINTMISS option in the TABLE statement.
Note: Use care when you use PRELOADFMT with PRINTMISS. This feature creates all possible combinations of formatted class variables. Some of these combinations may not make sense.
Featured in: Example 3 on page 1251
STYLE=< style-element-name PARENT>[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]
specifies the style element to use for page dimension text and class variable name headings. For information about the arguments of this option, and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Note: When you use STYLE= in the CLASS statement, it differs slightly from its use in the PROC TABULATE statement. In the CLASS statement, the parent of the heading is the page dimension text or heading under which the current heading is nested.
Note: If a page dimension expression contains multiple nested elements, then the Beforecaption style element is the style element of the first element in the nesting.
Alias: S=
Restriction: This option affects only the HTML, RTF, and Printer destinations.
Tip: To override a style element that is specified for page dimension text in the CLASS statement, you can specify a style element in the TABLE statement page dimension expression.
Tip: To override a style element that is specified for a class variable name heading in the CLASS statement, you can specify a style element in the related TABLE statement dimension expression.
Featured in: Example 14 on page 1293
By default, if an observation contains a missing value for any class variable, then PROC TABULATE excludes that observation from all tables that it creates. CLASS statements apply to all TABLE statements in the PROC TABULATE step. Therefore, if you define a variable as a class variable, then PROC TABULATE omits observations that have missing values for that variable from every table even if the variable does not appear in the TABLE statement for one or more tables.
If you specify the MISSING option in the PROC TABULATE statement, then the procedure considers missing values as valid levels for all class variables. If you specify the MISSING option in a CLASS statement, then PROC TABULATE considers missing values as valid levels for the class variable(s) that are specified in that CLASS statement.
Specifies a style element for class variable level value headings.
Restriction: This statement affects only the HTML, RTF, and Printer destinations.
CLASSLEV variable(s) / STYLE =< style-element-name PARENT>
[ style-attribute-name = style-attribute-value <
style-attribute-name = style-attribute-value >] ;
variable(s)
specifies one or more class variables from the CLASS statement for which you want to specify a style element.
STYLE=< style-element-name PARENT>[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]
specifies a style element for class variable level value headings. For information on the arguments of this option and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Note: When you use STYLE= in the CLASSLEV statement, it differs slightly from its use in the PROC TABULATE statement. In the CLASSLEV statement, the parent of the heading is the heading under which the current heading is nested.
Alias: S=
Restriction: This option affects only the HTML, RTF, and Printer destinations.
Tip: To override a style element that is specified in the CLASSLEV statement, you can specify a style element in the related TABLE statement dimension expression.
Featured in: Example 14 on page 1293
Specifies a numeric variable that contains the frequency of each observation.
Tip: The effects of the FREQ and WEIGHT statements are similar except when calculating degrees of freedom.
See also: For an example that uses the FREQ statement, see FREQ on page 61.
FREQ variable ;
variable
specifies a numeric variable whose value represents the frequency of the observation. If you use the FREQ statement, then the procedure assumes that each observation represents n observations, where n is the value of variable . If n is not an integer, then SAS truncates it. If n is less than 1 or is missing, then the procedure does not use that observation to calculate statistics.
The sum of the frequency variable represents the total number of observations.
Labels a keyword for the duration of the PROC TABULATE step. PROC TABULATE uses the label anywhere that the specified keyword would otherwise appear.
KEYLABEL keyword-1= description-1
< keyword-n= description-n >;
keyword
is one of the keywords for statistics that is discussed in Statistics That Are Available in PROC TABULATE on page 1227 or is the universal class variable ALL (see Elements That You Can Use in a Dimension Expression on page 1222).
description
is up to 256 characters to use as a label. As the syntax shows, you must enclose description in quotation marks.
Restriction: Each keyword can have only one label in a particular PROC TABULATE step; if you request multiple labels for the same keyword, then PROC TABULATE uses the last one that is specified in the step.
Specifies a style element for keyword headings.
Restriction: This statement affects only the HTML, RTF, and Printer output.
KEYWORD keyword(s) / STYLE =< style-element-name PARENT>
[ style-attribute-name = style-attribute-value <
style-attribute-name = style-attribute-value >] ;
keyword
is one of the keywords for statistics that is discussed in Statistics That Are Available in PROC TABULATE on page 1227 or is the universal class variable ALL (see Elements That You Can Use in a Dimension Expression on page 1222).
STYLE=< style-element-name PARENT>[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]
specifies a style element for the keyword headings. For information on the arguments of this option and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Note: When you use STYLE= in the KEYWORD statement, it differs slightly from its use in the PROC TABULATE statement. In the KEYWORD statement, the parent of the heading is the heading under which the current heading is nested.
Alias: S=
Restriction: This option affects only the HTML, RTF, and Printer destinations.
Tip: To override a style element that is specified in the KEYWORD statement, you can specify a style element in the related TABLE statement dimension expression.
Featured in: Example 14 on page 1293
Describes a table to print.
Requirement: All variables in the TABLE statement must appear in either the VAR statement or the CLASS statement.
Tip: Use multiple TABLE statements to create several tables.
TABLE << page-expression ,> row-expression ,>
column-expression </ table-option(s) >;
column-expression
defines the columns in the table. For information on constructing dimension expressions, see Constructing Dimension Expressions on page 1222.
Restriction: A column dimension is the last dimension in a TABLE statement. A row dimension or a row dimension and a page dimension may precede a column dimension.
To do this | Use this option | |
---|---|---|
Add dimensions | ||
Define the pages in a table | page-expression | |
Define the rows in a table | row-expression | |
Customize the HTML contents entry link to the output | CONTENTS= | |
Modify the appearance of the table | ||
Change the order of precedence for specified format modifiers | FORMAT_PRECEDENCE= | |
Specify a style element for various parts of the table | STYLE= | |
Change the order of precedence for specified style attribute values | STYLE_PRECEDENCE= | |
Customize text in the table | ||
Specify the text to place in the empty box above row titles | BOX= | |
Supply up to 256 characters to print in table cells that contain missing values | MISSTEXT= | |
Suppress the continuation message for tables that span multiple physical pages | NOCONTINUED | |
Modify the layout of the table | ||
Print as many complete logical pages as possible on a single printed page or, if possible, print multiple pages of tables that are too wide to fit on a page one below the other on a single page, instead of on separate pages. | CONDENSE | |
Create the same row and column headings for all logical pages of the table | PRINTMISS | |
Customize row headings | ||
Specify the number of spaces to indent nested row headings | INDENT= | |
Control allocation of space for row titles within the available space | ROW= | |
Specify the number of print positions available for row titles | RTSPACE= |
BOX= value
BOX={< label = value >
<STYLE=< style-element-name >[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]>}
specifies text and a style element for the empty box above the row titles.
Value can be one of the following:
_PAGE_
writes the page-dimension text in the box. If the page-dimension text does not fit, then it is placed in its default position above the box, and the box remains empty.
string
writes the quoted string in the box. Any string that does not fit in the box is truncated.
variable
writes the name (or label, if the variable has one) of a variable in the box. Any name or label that does not fit in the box is truncated.
For details about the arguments of the STYLE= option and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Featured in: Example 9 on page 1267 and Example 14 on page 1293
CONDENSE
prints as many complete logical pages as possible on a single printed page or, if possible, prints multiple pages of tables that are too wide to fit on a page one below the other on a single page, instead of on separate pages. A logical page is all the rows and columns that fall within one of the following:
a page-dimension category (with no BY-group processing)
a BY group with no page dimension
a page-dimension category within a single BY group.
Restrictions: CONDENSE has no effect on the pages that are generated by the BY statement. The first table for a BY group always begins on a new page.
Featured in: Example 9 on page 1267
CONTENTS= link-name
enables you to name the link in the HTML table of contents that points to the ODS output of the table that is produced by using the TABLE statement.
Note: CONTENTS= affects only the contents file of ODS HTML output. It has no effect on the actual TABULATE procedure reports.
FORMAT_PRECEDENCE=PAGEROWCOLUMNCOL
specifies whether the format that is specified for the page dimension (PAGE), row dimension (ROW), or column dimension (COLUMN or COL) is applied to the contents of the table cells.
Default: COLUMN
FUZZ= number
supplies a numeric value against which analysis variable values and table cell values other than frequency counts are compared to eliminate trivial values (absolute values less than the FUZZ= value) from computation and printing. A number whose absolute value is less than the FUZZ= value is treated as zero in computations and printing. The default value is the smallest representable floating-point number on the computer that you are using.
INDENT= number-of-spaces
specifies the number of spaces to indent nested row headings, and suppresses the row headings for class variables.
Tip: When there are no crossings in the row dimension, there is nothing to indent, so the value of number-of-spaces has no effect. However, in such cases INDENT= still suppresses the row headings for class variables.
Restriction: In the HTML, RTF, and Printer destinations, the INDENT= option suppresses the row headings for class variables but does not indent nested row headings.
Featured in: Example 8 on page 1265 (with crossings) and Example 9 on page 1267 (without crossings)
MISSTEXT = text
MISSTEXT ={< label = text > < STYLE =< style-element-name >
[ style-attribute-name = style-attribute-value <
style-attribute-name = style-attribute-value >]>}
supplies up to 256 characters of text to print and specifies a style element for table cells that contain missing values. For details on the arguments of the STYLE= option and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Interaction: A style element that is specified in a dimension expression overrides a style element that is specified in the MISSTEXT= option for any given cell(s).
Featured in: Providing Text for Cells That Contain Missing Values on page 1242 and Example 14 on page 1293
NOCONTINUED
suppresses the continuation message, continued , that is displayed at the bottom of tables that span multiple pages. The text is rendered with the Aftercaption style element.
Note: Because HTML browsers do not break pages, NOCONTINUED has no effect on the HTML destination.
page-expression
defines the pages in a table. For information on constructing dimension expressions, see Constructing Dimension Expressions on page 1222.
Restriction: A page dimension is the first dimension in a table statement. Both a row dimension and a column dimension must follow a page dimension.
Featured in: Example 9 on page 1267
PRINTMISS
prints all values that occur for a class variable each time headings for that variable are printed, even if there are no data for some of the cells that these headings create. Consequently, PRINTMISS creates row and column headings that are the same for all logical pages of the table, within a single BY group.
Default: If you omit PRINTMISS, then PROC TABULATE suppresses a row or column for which there are no data, unless you use the CLASSDATA= option in the PROC TABULATE statement.
Restrictions: If an entire logical page contains only missing values, then that page does not print regardless of the PRINTMISS option.
See also: CLASSDATA= option on page 1202
Featured in: Providing Headings for All Categories on page 1241
ROW= spacing
specifies whether all title elements in a row crossing are allotted space even when they are blank. The possible values for spacing are as follows:
CONSTANT
allots space to all row titles even if the title has been blanked out (for example, N= ).
Alias: CONST
FLOAT
divides the row title space equally among the nonblank row titles in the crossing.
Default: CONSTANT
Featured in: Example 7 on page 1263
row-expression
defines the rows in the table. For information on constructing dimension expressions, see Constructing Dimension Expressions on page 1222.
Restriction: A row dimension is the next to last dimension in a table statement. A column dimension must follow a row dimension. A page dimension may precede a row dimension.
RTSPACE= number
specifies the number of print positions to allot to all of the headings in the row dimension, including spaces that are used to print outlining characters for the row headings. PROC TABULATE divides this space equally among all levels of row headings.
Alias: RTS=
Default: one-fourth of the value of the SAS system option LINESIZE=
Restriction: The RTSPACE= option affects only the traditional SAS monospace output destination.
Interaction: By default, PROC TABULATE allots space to row titles that are blank. Use ROW=FLOAT in the TABLE statement to divide the space among only nonblank titles.
See also: For more information about controlling the space for row titles, see Chapter 5, Controlling the Table s Appearance, in SAS Guide to TABULATE Processing .
Featured in: Example 1 on page 1246
STYLE=< style-element-name >[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]
specifies a style element to use for parts of the table other than table cells. For information about the arguments of this option and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Note: The list of attributes that you can set or change with the STYLE= option in the TABLE statement differs from that of the PROC TABULATE statement.
The following table shows the attributes that you can set or change with the STYLE= option in the TABLE statement. Most of these attributes apply to parts of the table other than cells (for example, table borders and the lines between columns and rows). Attributes that you apply in the PROC TABULATE statement and in other locations in the PROC TABULATE step apply to cells within the table. Note that not all attributes are valid in all destinations. See The Complete Guide to the SAS Output Delivery System for more information about these style attributes, their valid values, and their applicable destinations.
BACKGROUND= | FONT_WIDTH= [*] |
BACKGROUNDIMAGE= | FOREGROUND= [*] |
BORDERCOLOR= | FRAME= |
BORDERCOLORDARK= | HTMLCLASS= |
BORDERCOLORLIGHT= | JUST= |
BORDERWIDTH= | OUTPUTWIDTH= |
CELLPADDING = | POSTHTML= |
CELLSPACING= | POSTIMAGE= |
FONT= [*] | POSTTEXT= |
FONT_FACE= [*] | PREHTML= |
FONT_SIZE= [*] | PREIMAGE= |
FONT_STYLE= [*] | PRETEXT= |
FONT_WEIGHT= [*] | RULES= |
[*] When you use these attributes in this location, they affect only the text that is specified with the PRETEXT=, POSTTEXT=, PREHTML=, and POSTHTML= attributes. To alter the foreground color or the font for the text that appears in the table, you must set the corresponding attribute in a location that affects the cells rather than the table. |
Note: You can use braces ({ and }) instead of square brackets ([ and ]).
Alias: S=
Restriction: This option affects only the HTML, RTF, and Printer destinations.
Tip: To override a style element specification that is made as an option in the TABLE statement, specify STYLE= in a dimension expression of the TABLE statement.
Featured in: Example 14 on page 1293
STYLE_PRECEDENCE=PAGEROWCOLUMNCOL
specifies whether the style that is specified for the page dimension (PAGE), row dimension (ROW), or column dimension (COLUMN or COL) is applied to the contents of the table cells.
Default: COLUMN
A dimension expression defines the content and appearance of a dimension (the columns, rows, or pages in the table) by specifying the combination of variables, variable values, and statistics that make up that dimension. A TABLE statement consists of from one to three dimension expressions separated by commas. Options can follow the dimension expressions.
If all three dimensions are specified, then the leftmost dimension expression defines pages, the middle dimension expression defines rows, and the rightmost dimension expression defines columns. If two dimensions are specified, then the left dimension expression defines rows, and the right dimension expression defines columns. If a single dimension is specified, then the dimension expression defines columns.
A dimension expression is composed of one or more elements and operators.
analysis variables
(see VAR Statement on page 1225).
class variables
(see CLASS Statement on page 1211).
the universal class variable ALL
summarizes all of the categories for class variables in the same parenthetical group or dimension (if the variable ALL is not contained in a parenthetical group).
Featured in: Example 6 on page 1260, Example 9 on page 1267, and Example 13 on page 1283
Note: If the input data set contains a variable named ALL, then enclose the name of the universal class variable in quotation marks.
keywords for statistics
See Statistics That Are Available in PROC TABULATE on page 1227 for a list of available statistics. Use the asterisk (*) operator to associate a statistic keyword with a variable. The N statistic (number of nonmissing values) can be specified in a dimension expression without associating it with a variable.
Restriction: Statistic keywords other than N must be associated with an analysis variable.
Default: For analysis variables, the default statistic is SUM. Otherwise, the default statistic is N.
Examples:
n Region*n Sales*max
Featured in: Example 10 on page 1269 and Example 13 on page 1283
format modifiers
define how to format values in cells. Use the asterisk (*) operator to associate a format modifier with the element (an analysis variable or a statistic) that produces the cells that you want to format. Format modifiers have the form
f= format
Example:
Sales*f=dollar8.2
Tip: Format modifiers have no effect on CLASS variables.
See also: For more information on specifying formats in tables, see Formatting Values in Tables on page 1229.
Featured in: Example 6 on page 1260
labels
temporarily replace the names of variables and statistics. Labels affect only the variable or statistic that immediately precedes the label. Labels have the form
statistic-keyword-or-variable-name =' label-text '
Tip: PROC TABULATE eliminates the space for blank column headings from a table but by default does not eliminate the space for blank row headings unless all row headings are blank. Use ROW=FLOAT in the TABLE statement to remove the space for blank row headings.
Examples:
Region='Geographical Region' Sales*max='Largest Sale'
Featured in: Example 5 on page 1258 and Example 7 on page 1263
style-element specifications
specify style elements for page dimension text, headings, or data cells. For details, see Specifying Style Elements in Dimension Expressions on page 1224.
asterisk *
creates categories from the combination of values of the class variables and constructs the appropriate headers for the dimension. If one of the elements is an analysis variable, then the statistics for the analysis variable are calculated for the categories that are created by the class variables. This process is called crossing .
Examples:
Region*Division Quarter*Sales*f=dollar8.2
Featured in: Example 1 on page 1246
(blank)
places the output for each element immediately after the output for the preceding element. This process is called concatenation .
Example:
n Region*Sales ALL
Featured in: Example 6 on page 1260
parentheses ()
group elements and associate an operator with each concatenated element in the group.
Examples:
Division*(Sales*max Sales*min) (Region ALL)*Sales
Featured in: Example 6 on page 1260
angle brackets <>
specify denominator definitions, which determine the value of the denominator in the calculation of a percentage. For a discussion of how to construct denominator definitions, see Calculating Percentages on page 1230.
Featured in: Example 10 on page 1269 and Example 13 on page 1283
You can specify a style element in a dimension expression to control the appearance in HTML, RTF, and Printer output of the following table elements:
analysis variable name headings
class variable name headings
class variable level value headings
data cells
keyword headings
page dimension text
Specifying a style element in a dimension expression is useful when you want to override a style element that you have specified in another statement, such as the PROC TABULATE, CLASS, CLASSLEV, KEYWORD, TABLE, or VAR statements.
The syntax for specifying a style element in a dimension expression is
[STYLE<(CLASSLEV)>=< style-element-name
PARENT>[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]]
Some examples of style elements in dimension expressions are
dept={label='Department' style=[foreground=red]}, N dept*[style= MyDataStyle ], N dept*[format=12.2 style= MyDataStyle ], N
Note: When used in a dimension expression, the STYLE= option must be enclosed within square brackets ([ and ]) or braces ({ and }).
With the exception of (CLASSLEV), all arguments are described in STYLE= on page 1208 in the PROC TABULATE statement.
(CLASSLEV)
assigns a style element to a class variable level value heading. For example, the following TABLE statement specifies that the level value heading for the class variable, DEPT, has a foreground color of yellow:
table dept=[style(classlev)= [foreground=yellow]]*sales;
Note: This option is used only in dimension expressions.
For an example that shows how to specify style elements within dimension expressions, see Example 14 on page 1293.
Identifies numeric variables to use as analysis variables.
Alias: VARIABLES
Tip: You can use multiple VAR statements.
VAR analysis-variable(s) </ option(s) >;
analysis-variable(s);
identifies the analysis variables in the table. Analysis variables are numeric variables for which PROC TABULATE calculates statistics. The values of an analysis variable can be continuous or discrete.
If an observation contains a missing value for an analysis variable, then PROC TABULATE omits that value from calculations of all statistics except N (the number of observations with nonmissing variable values) and NMISS (the number of observations with missing variable values). For example, the missing value does not increase the SUM, and it is not counted when you are calculating statistics such as the MEAN.
STYLE=< style-element-name PARENT>[ style-attribute-name = style-attribute-value < style-attribute-name = style-attribute-value >]
specifies a style element for analysis variable name headings. For information on the arguments of this option and how it is used, see STYLE= on page 1208 in the PROC TABULATE statement.
Note: When you use STYLE= in the VAR statement, it differs slightly from its use in the PROC TABULATE statement. In the VAR statement, the parent of the heading is the heading under which the current heading is nested.
Alias: S=
Restriction: This option affects only the HTML, RTF, and Printer destinations.
Tip: To override a style element that is specified in the VAR statement, you can specify a style element in the related TABLE statement dimension expression.
Featured in: Example 14 on page 1293
WEIGHT= weight-variable
specifies a numeric variable whose values weight the values of the variables that are specified in the VAR statement. The variable does not have to be an integer. If the value of the weight variable is
Weight value | PROC TABULATE |
| counts the observation in the total number of observations |
less than 0 | converts the value to zero and counts the observation in the total number of observations |
missing | excludes the observation |
To exclude observations that contain negative and zero weights from the analysis, use EXCLNPWGT. Note that most SAS/STAT procedures, such as PROC GLM, exclude negative and zero weights by default.
Restriction: To compute weighted quantiles, use QMETHOD=OS in the PROC statement.
Tip: When you use the WEIGHT= option, consider which value of the VARDEF= option is appropriate (see the discussion of VARDEF= on page 1209).
Tip: Use the WEIGHT option in multiple VAR statements to specify different weights for the analysis variables.
Note: Prior to Version 7 of SAS, the procedure did not exclude the observations with missing weights from the count of observations.
Specifies weights for analysis variables in the statistical calculations.
See also: For information on calculating weighted statistics and for an example that uses the WEIGHT statement, see Calculating Weighted Statistics on page 64
WEIGHT variable ;
variable
specifies a numeric variable whose values weight the values of the analysis variables. The values of the variable do not have to be integers. PROC TABULATE responds to weight values in accordance with the following table.
Weight value | PROC TABULATE response |
| counts the observation in the total number of observations |
less than 0 | converts the value to zero and counts the observation in the total number of observations |
missing | excludes the observation |
To exclude observations that contain negative and zero weights from the analysis, use EXCLNPWGT. Note that most SAS/STAT procedures, such as PROC GLM, exclude negative and zero weights by default.
Restriction: To compute weighted quantiles, use QMETHOD=OS in the PROC statement.
Interaction: If you use the WEIGHT= option in a VAR statement to specify a weight variable, then PROC TABULATE uses this variable instead to weight those VAR statement variables.
Tip: When you use the WEIGHT statement, consider which value of the VARDEF= option is appropriate. See the discussion of VARDEF= on page 1209 and the calculation of weighted statistics in Keywords and Formulas on page 1354 for more information.
Note: Prior to Version 7 of SAS, the procedure did not exclude the observations with missing weights from the count of observations.