REPORT Procedure

DEFINE Statement

Describes how to use and display a report item.
Restriction: A weight cannot be applied to a report-item alias without also applying it to the report-item. The WEIGHT= option must appear in the DEFINE statement for the report-item.
Tip: If you do not use a DEFINE statement, then PROC REPORT uses default characteristics.
Ordering the Rows in a Report

Using Aliases to Obtain Multiple Statistics for the Same Variable

Consolidating Multiple Observations into One Row of a Report

Creating a Column for Each Value of a Variable

Displaying Multiple Statistics for One Variable

Writing a Customized Summary on Each Page

Calculating Percentages

Creating and Processing an Output Data Set

Storing Computed Variables as Part of a Data Set

Using a Format to Create Groups

Specifying Style Elements for ODS Output in Multiple Statements

Using Multilabel Formats

Using the WIDTH= and CELLWIDTH= Style Attributes with PROC REPORT

Syntax

DEFINE report-item / <option(s)>;

Summary of Optional Arguments

Control the placement of values and column headings
centers the formatted values of the report item within the column width and center the column heading over the values.
specifies the color in the REPORT window of the column heading and of the values of the item that you define.
defines the column heading for the report item.
left-justifies the formatted values of the report item within the column width and left-justifies the column headings over the values.
right-justifies the formatted values of the report item within the column width and right-justifies the column headings over the values.
Customize the appearance of a report item
excludes all combinations of the item that are not found in the preloaded range of user-defined formats.
assigns a SAS or user-defined format to the item.
references a HELP or CBT entry that contains Help information for the report item.
considers missing values as valid values for the item.
enables PROC REPORT to use the format label or labels to create subgroup combinations that have multilabel formats.
orders the values of a group, order, or across variable according to the specified order.
specifies that all formats are preloaded for the item.
for traditional SAS monospace output, defines the number of blank characters to leave between the column being defined and the column immediately to its left.
associates a statistic with an analysis variable.
specifies a style element (for the Output Delivery System) for the report item.
specifies a numeric variable whose values weight the value of the analysis variable.
defines the width of the column in which PROC REPORT displays the report item.
Specify how to use a report item
defines the item, which must be a data set variable, as an across variable.
defines the item, which must be a data set variable, as an analysis variable.
defines the item as a computed variable.
defines the item, which must be a data set variable, as a display variable.
defines the item, which must be a data set variable, as a group variable.
defines the item, which must be a data set variable, as an order variable.
Specify options for a report item
creates a link in the table of contents.
reverses the order in which PROC REPORT displays rows or values of a group, order, or across variable.
wraps the value of a character variable in its column.
specifies that the item that you are defining is an ID variable.
suppresses the display of the report item.
suppresses the display of the report item if its values are all zero or missing.
inserts a page break just before printing the first column containing values of the report item.

Required Argument

report-item
specifies the name or alias (established in the COLUMN statement) of the data set variable, computed variable, or statistic to define. These are types of names that can be used for report-item:
  • a SAS identifier (determined by the VALIDVARNAME option)
  • a name literal
  • a numbered range list
  • a name range list
  • a special name list
  • a name prefix list
  • a statistic
Notes:The names in variable range lists refer to variables in the input data set, not statistic names or computed variable names. Use only one name for each DEFINE statement. That one name, however, can be a range list. Example syntax using a variable range list is: DEFINE Var1–Var3/ width=10 center “#Visit#Date”;

Do not specify a usage option in the definition of a statistic. The name of the statistic tells PROC REPORT how to use it.

See:Names in the SAS Language in SAS Language Reference: Concepts, SAS Variable Lists in SAS Language Reference: Concepts, and VALIDVARNAME= System Option in SAS System Options: Reference.

Optional Arguments

ACROSS
defines report-item, which must be a data set variable, as an across variable. (See Across Variables.)
ANALYSIS
defines report-item, which must be a data set variable, as an analysis variable. (See Analysis Variables.)
By default, PROC REPORT calculates the Sum statistic for an analysis variable. Specify an alternate statistic with the statistic option in the DEFINE statement.
Note: Naming a statistic in the DEFINE statement implies the ANALYSIS option, so you never need to specify ANALYSIS. However, specifying ANALYSIS can make your code easier for novice users to understand.
Note: Special missing values show up as missing values when they are defined as ANALYSIS variables.
CENTER
centers the formatted values of the report item within the column width and centers the column heading over the values. This option has no effect on the CENTER option in the PROC REPORT statement, which centers the report on the page.
COLOR=color
specifies the color in the REPORT window of the column heading and of the values of the item that you are defining. You can use the following colors:
BLACK
MAGENTA
BLUE
ORANGE
BROWN
PINK
CYAN
RED
GRAY
WHITE
GREEN
YELLOW
Note: Not all operating environments and devices support all colors, and in some operating environments and devices, one color might map to another color. For example, if the DEFINITION window displays the word BROWN in yellow characters, then selecting BROWN results in a yellow item.
Default:The color of Foreground in the SASCOLOR window. (For more information, see the online Help for the SASCOLOR window.)
Restriction:This option affects output in the interactive report window environment only.
column-header
defines the column heading for the report item. Enclose each heading in single or double quotation marks. When you specify multiple column headings, PROC REPORT uses a separate line for each one. The split character also splits a column heading over multiple lines.
In traditional (monospace) SAS output, if the first and last characters of a heading are one of the following characters, then PROC REPORT uses that character to expand the heading to fill the space over the column: :− = \_ .* +
Similarly, if the first character of a heading is < and the last character is >, or vice versa, then PROC REPORT expands the heading to fill the space over the column by repeating the first character before the text of the heading and the last character after it.
The following table shows the defaults variables and statistics:
Item
Header
Variable without a label
Variable name
Variable with a label
Variable label
Statistic
Statistic name
Tips:If you want to use names when labels exist, then submit the following SAS statement before invoking PROC REPORT: options nolabel;

HEADLINE underlines all column headings and the spaces between them. In traditional (monospace) SAS output, you can underline column headings without underlining the spaces between them, by using the special characters '--' as the last line of each column heading instead of using HEADLINE. (See Consolidating Multiple Observations into One Row of a Report.)

COMPUTED
defines the specified item as a computed variable. Computed variables are variables that you define for the report. They are not in the input data set, and PROC REPORT does not add them to the input data set.
In the interactive report window environment, you add a computed variable to a report from the COMPUTED VAR window.
In the nonwindowing environment, you add a computed variable by
  • including the computed variable in the COLUMN statement
  • defining the variable's usage as COMPUTED in the DEFINE statement
  • computing the value of the variable in a compute block associated with the variable
CONTENTS='link-text'
specifies the text for the entries in the HTML contents file or PDF table of contents for the output that is produced by PROC REPORT. If the DEFINE statement has the PAGE= option and the CONTENTS= option specified with a link-text value assigned, then PROC REPORT adds a directory to the table of contents and uses the value of link-text as a link for tables created in the table of contents.
For information about HTML and PDF output, see Output Delivery System.
Default:If the DEFINE statement has a PAGE option, but does not have a CONTENTS= option specified, then a directory is created with the directory text as COLA-COLB. COLA is the name or alias of the leftmost column and COLB is the name or alias of the rightmost column. If the table has only one column, then the directory text is the column name or alias.
Restrictions:For HTML output, the CONTENTS= option has no effect in the HTML body file. It affects only the HTML contents file.

If CONTENTS= is specified, but no PAGE option is specified, then PROC REPORT generates a warning message in the SAS log file.

Interactions:If the DEFINE statement has a page option and there is a BREAK BEFORE statement with a PAGE option and the CONTENTS= option specified has a value other than empty quotation marks, then PROC REPORT adds a directory to the table of contents and puts links to the tables in that directory.

If the DEFINE statement has a PAGE option and there is a BREAK BEFORE statement with no PAGE option, then PROC REPORT does not create a directory in the table of contents. Instead, PROC REPORT uses the CONTENTS= value from the DEFINE statement to create links to the table of contents. If there is no CONTENTS= option in the DEFINE statement, then PROC REPORT creates links using the default text COLA–COLB. Refer to the Default explanation above.

If there is a BREAK BEFORE statement with a CONTENTS=' ' option specified and a PAGE option specified, then PROC REPORT does not create a directory in the table of contents. Instead, PROC REPORT uses the CONTENTS= value from the DEFINE statement to create links to the table of contents. If there is no CONTENTS= option in the DEFINE statement, then PROC REPORT creates links using the default text COLA–COLB. Refer to the Default explanation above.

For RTF output, the CONTENTS= option has no effect on the RTF body file unless you turn on the CONTENTS=YES option in the ODS RTF statement. In that case, a Table of Contents page is inserted at the front of your RTF output file. Your CONTENTS= option text from PROC REPORT will then show up in this separate Table of Contents page.

Tips:If the DEFINE statement has the CONTENTS= option specified where the value is empty quotation marks, then the directory to the table of contents is not added. An example of this code is as follows: CONTENTS=''

If there are multiple BREAK BEFORE statements, then the link text is the concatenation of all of the CONTENTS= values or of all the default values.

DESCENDING
reverses the order in which PROC REPORT displays rows or values of a group, order, or across variable.
Tip:By default, PROC REPORT orders group, order, and across variables by their formatted values. Use the ORDER= option in the DEFINE statement to specify an alternate sort order.
DISPLAY
defines report-item, which must be a data set variable, as a display variable. (See Display Variables.)
EXCLUSIVE
excludes from the report and the output data set all combinations of the group variables and the across variables that are not found in the preloaded range of user-defined formats.
Requirement:You must specify the PRELOADFMT option in the DEFINE statement in order to preload the variable formats.
FLOW
wraps the value of a character variable in its column. The FLOW option honors the split character. If the text contains no split character, then PROC REPORT tries to split text at a blank.
Restriction:This option has no effect on ODS destinations other than traditional SAS monospace output.
FORMAT=format
assigns a SAS or user-defined format to the item. This format applies to report-item as PROC REPORT displays it; the format does not alter the format associated with a variable in the data set. For data set variables, PROC REPORT honors the first of these formats that it finds:
  • the format that is assigned with FORMAT= in the DEFINE statement
  • the format that is assigned in a FORMAT statement when you invoke PROC REPORT
  • the format that is associated with the variable in the data set
If none of these formats is present, then PROC REPORT uses BESTw. for numeric variables and $w. for character variables. The value of w is the default column width. For character variables in the input data set, the default column width is the variable's length. For numeric variables in the input data set and for computed variables (both numeric and character), the default column width is the value specified by COLWIDTH= in the PROC REPORT statement or in the ROPTIONS window.
In the interactive report window environment, if you are unsure what format to use, then type a question mark (?) in the format field in the DEFINITION window to access the FORMATS window.
GROUP
defines report-item, which must be a data set variable, as a group variable. (See Group Variables.)
ID
specifies that the item that you are defining is an ID variable. An ID variable and all columns to its left appear at the left of every page of a report. ID ensures that you can identify each row of the report when the report contains more columns than will fit on one page.
ITEMHELP=entry-name
references a HELP or CBT entry that contains help information for the report item. Use PROC BUILD in SAS/AF software to create a HELP or CBT entry for a report item. All HELP and CBT entries for a report must be in the same catalog, and you must specify that catalog with the HELP= option in the PROC REPORT statement or from the User Help fields in the ROPTIONS window.
Of course, you can access these entries only from an interactive report window environment. To access a Help entry from the report, select the item and issue the HELP command. PROC REPORT first searches for and displays an entry named entry-name.CBT. If no such entry exists, then PROC REPORT searches for entry-name.HELP. If neither a CBT nor a HELP entry for the selected item exists, then the opening frame of the Help for PROC REPORT is displayed.
LEFT
left-justifies the formatted values of the report item within the column width and left-justifies the column headings over the values. If the format width is the same as the width of the column, then the LEFT option has no effect on the placement of values.
Restriction:This option only affects the LISTING output. It has no effect on other ODS output.
MISSING
considers missing values as valid values for the report item. 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 the MISSING option, then PROC REPORT excludes from the report and the output data sets all observations that have a missing value for any group, order, or across variable.
MLF
enables PROC REPORT to use the format label or labels for a given range or for overlapping ranges to create subgroup combinations that use multilabel formatting. These multilabel formats are used only with group and across variables.
MLF is supported on all ODS destinations, the LISTING destination, data sets, and the REPORT WINDOW.
Note: PROC REPORT supports assigning a numeric variable that has a multilabel format to a character variable.
Requirement:Use PROC FORMAT and the MULTILABEL option in the VALUE statement to create a multilabel format.
Tips:The MLF option has no effect unless the variable is associated with a multilabel format. If the column does not have a MULTILABEL format associated with it, then an additional FORMAT statement or FORMAT= option in the DEFINE statement is needed to associate an existing format or informat with one or more variables. If the column already has a MULTILABEL format associated with it (using any regular method to associate a format with the variable), then no additional FORMAT statement or FORMAT= option is needed.

If the MLF option is omitted, PROC REPORT uses the primary format labels to determine the subgroup combinations. The primary format labels correspond to the first external format value.

See:MULTILABEL option in the VALUE statement of the FORMAT procedure.
NOPRINT
suppresses the display of the report item. Use this option
  • if you do not want to show the item in the report but you need to use its values to calculate other values that you use in the report.
  • to establish the order of rows in the report.
  • if you do not want to use the item as a column but want to have access to its values in summaries. (See Writing a Customized Summary on Each Page.)
Interactions:Even though the columns that you define with NOPRINT do not appear in the report, you must count them when you are referencing columns by number. (See Four Ways to Reference Report Items in a Compute Block.)

SHOWALL in the PROC REPORT statement or the ROPTIONS window overrides all occurrences of NOPRINT.

NOZERO
suppresses the display of the report item if its values are all zero or missing.
Restriction:This option has no effect on ODS destinations other than traditional SAS monospace output.
Interactions:Even though the columns that you define with NOZERO do not appear in the report, you must count them when you are referencing columns by number. (See Four Ways to Reference Report Items in a Compute Block.)

SHOWALL in the PROC REPORT statement or in the ROPTIONS window overrides all occurrences of NOZERO.

ORDER
defines report-item, which must be a data set variable, as an order variable. (See Order Variables.)
ORDER=DATA|FORMATTED|FREQ|INTERNAL
orders the values of a group, order, or across variable according to the specified order, where
DATA
orders values according to their order in the input data set.
FORMATTED
orders values by their formatted (external) values. If no format has been assigned to a class variable, then the default format, BEST12., is used.
FREQ
orders values by ascending frequency count.
INTERNAL
orders values by their unformatted values, which yields the same order that PROC SORT would yield. This order is operating environment-dependent. This sort sequence is particularly useful for displaying dates chronologically.
Default:FORMATTED
Interaction:DESCENDING in the item's definition reverses the sort sequence for an item. By default, the order is ascending.
Note:The default value for the ORDER= option in PROC REPORT is not the same as the default value in other SAS procedures. In other SAS procedures, the default is ORDER=INTERNAL. The default for the option in PROC REPORT might change in a future release to be consistent with other procedures. Therefore, in production jobs where it is important to order report items by their formatted values, specify ORDER=FORMATTED even though it is currently the default. Doing so ensures that PROC REPORT will continue to produce the reports that you expect even if the default changes.
PAGE
inserts a page break just before printing the first column containing values of the report item.
Restriction:This option has no affect on the OUTPUT destination.
Interaction:PAGE is ignored if you use WRAP in the PROC REPORT statement or in the ROPTIONS window.
Tip:In listing destinations, a PAGE option in the DEFINE statement causes PROC REPORT to print this column and all columns to its right on a new page. However, for ODS MARKUP, HTML, PRINTER , and RTF destinations, the page break does not occur until all the rows in the report have been printed. Therefore, PROC REPORT prints all the rows for all the columns to the left of the PAGE column and then starts over at the top of the report and prints the PAGE column and the columns to the right.
PRELOADFMT
specifies that the format is preloaded for the variable.
Restriction:PRELOADFMT applies only to group and across variables.
Requirement:PRELOADFMT has no effect unless you specify either EXCLUSIVE or ORDER=DATA and you assign a format to the variable.
Interactions:To limit the report to the combination of formatted variable values that are present in the input data set, use the EXCLUSIVE option in the DEFINE statement.

To include all ranges and values of the user-defined formats in the output, use the COMPLETEROWS option in the PROC REPORT statement.

Note:If you do not specify NOCOMPLETECOLS when you define the across variables, then the report includes a column for every formatted variable. If you specify COMPLETEROWS when you define the group variables, then the report includes a row for every formatted value. Some combinations of rows and columns might not make sense when the report includes a column for every formatted value of the across variable and a row for every formatted value of the group variable.
RIGHT
right-justifies the formatted values of the specified item within the column width and right-justifies the column headings over the values. If the format width is the same as the width of the column, then RIGHT has no effect on the placement of values.
Restriction:This option only affects the LISTING output. It has no affect on other ODS output.
SPACING=horizontal-positions
defines the number of blank characters to leave between the column being defined and the column immediately to its left. For each column, the sum of its width and the blank characters between it and the column to its left cannot exceed the line size.
Default:2
Restriction:This option has no effect on ODS destinations other than traditional SAS monospace output.
Interactions:When PROC REPORT's CENTER option is in effect, PROC REPORT ignores spacing that precedes the leftmost variable in the report.

SPACING= in an item's definition overrides the value of SPACING= in the PROC REPORT statement or in the ROPTIONS window.

statistic
associates a statistic with an analysis variable. You must associate a statistic with every analysis variable in its definition. PROC REPORT uses the statistic that you specify to calculate values for the analysis variable for the observations that are represented by each cell of the report. You cannot use statistic in the definition of any other type of variable.
See Statistics That Are Available in PROC REPORT for a list of available statistics.
Default:SUM
Note:PROC REPORT uses the name of the analysis variable as the default heading for the column. You can customize the column heading with the column-header option in the DEFINE statement.
STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]>
specifies the style element to use for column headings and for text inside cells for this report item. See Using Style Elements in PROC REPORT for details.
Restriction:This option affects only the HTML, RTF, and Printer destinations.
Tip:FONT names that contain characters other than letters or underscores must be enclosed in quotation marks.
WEIGHT=weight-variable
specifies a numeric variable whose values weight the values of the analysis variable that is specified in the DEFINE statement. The variable value does not have to be an integer. The following table describes how PROC REPORT treats various values of the WEIGHT variable.
Weight Value
PROC REPORT Response
0
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 the EXCLNPWGT option in the PROC REPORT statement. Note that most SAS/STAT procedures, such as PROC GLM, exclude negative and zero weights by default.
Alias:WGT=
Restrictions:to compute weighted quantiles, use QMETHOD=OS in the PROC REPORT statement.

A weight cannot be applied to a report-item alias without also applying it to the report-item. The WEIGHT= option must appear in the DEFINE statement for the report-item.

Note:Prior to Version 7 of SAS, the REPORT procedure did not exclude the observations with missing weights from the count of observations.
Tips:When you use the WEIGHT= option, consider which value of the VARDEF= option in the PROC REPORT statement is appropriate.

Use the WEIGHT= option in separate variable definitions in order to specify different weights for the variables.

WIDTH=column-width
defines the width of the column in which PROC REPORT displays report-item. This option only affects traditional SAS monospace output.
Default:A column width that is just large enough to handle the format. If there is no format, then PROC REPORT uses the value of the COLWIDTH= option in the PROC REPORT statement.
Range:1 to the value of the SAS system option LINESIZE=
Restriction:This option has no effect on ODS destinations other than traditional SAS monospace output. For ODS destinations, use the STYLE= option with the WIDTH= style attribute or the CELLWIDTH= style attribute. Refer to Style Attributes Tables in SAS Output Delivery System: User's Guide for details. See how style attributes WIDTH= and CELLWIDTH= can be used with PROC REPORT in Using the WIDTH= and CELLWIDTH= Style Attributes with PROC REPORT.
Interaction:WIDTH= in an item definition overrides the value of COLWIDTH= in the PROC REPORT statement or the ROPTIONS window.
Tip:When you stack items in the same column in a report, the width of the item that is at the bottom of the stack determines the width of the column.