Chapter Contents

Previous

Next
The REPORT Procedure

DEFINE Statement


Describes how to use and display a report item.

Tip: If you do not use a DEFINE statement, PROC REPORT uses default characteristics.
Featured in: 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 , and Calculating Percentages


DEFINE report-item / <usage>
<attribute(s)>
<option(s)>
<justification>
<COLOR=color>
<'column-header-1' <...'column-header-n'>>
<style>;

To do this Use this option
Specify how to use a report item (see Usage of Variables in a Report )

Define the item, which must be a data set variable, as an across variable ACROSS

Define the item, which must be a data set variable, as an analysis variable ANALYSIS

Define the item as a computed variable COMPUTED

Define the item, which must be a data set variable, as a display variable DISPLAY

Define the item, which must be a data set variable, as a group variable GROUP

Define the item, which must be a data set variable, as an order variable ORDER
Specify style attribute s for a report item

Assign a SAS or user-defined format to the item FORMAT=

Reference a HELP or CBT entry that contains Help information for the report item ITEMHELP=

Order the values of a group, order, or across variable according to the specified order ORDER=

Define the number of blank characters to leave between the column being defined and the column immediately to its left SPACING=

Associate a statistic with an analysis variable

Define the width of the column in which PROC REPORT displays the report item WIDTH=
Specify options for a report item

Reverse the order in which PROC REPORT displays rows or values of a group, order, or across variable DESCENDING

Wrap the value of a character variable in its column FLOW

Specify that the item that you are defining is an ID variable ID

Suppress the display of the report item NOPRINT

Suppress the display of the report item if its values are all zero or missing NOZERO

Insert a page break just before printing the first column containing values of the report item PAGE
Control the placement of values and column headers

Center the formatted values of the report item within the column width and center the column header over the values CENTER

Left-justify the formatted values of the report item within the column width and left-justify the column headers over the values LEFT

Right-justify the formatted values of the report item within the column width and right-justify the column headers over the values RIGHT

Specify the color in the REPORT window of the column header and of the values of the item that you define COLOR=

Define the column header for the report item column-header
Specify a style element (for the Output Delivery System) for the report item STYLE=


Required Arguments

report-item
specifies the name or alias (established in the COLUMN statement) of the data set variable, computed variable, or statistic to define.

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


Options

ACROSS
defines item, which must be a data set variable, as an across variable. (See Across Variables .)
Featured in: Creating a Column for Each Value of a Variable

ANALYSIS
defines 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 may make your code easier for novice users to understand.  [cautionend]
Featured in: Ordering the Rows in a Report , Using Aliases to Obtain Multiple Statistics for the Same Variable , and Consolidating Multiple Observations into One Row of a Report

CENTER
centers the formatted values of the report item within the column width and centers the column header 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 header 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

Default: The color of Foreground in the SASCOLOR window. (For more information, see the online Help for the SASCOLOR window.)
Restriction: This option has no effect on the HTML or Printer output.

Note:   Not all operating environments and devices support all colors, and in some operating environments and devices, one color may map to another color. For example, if the DEFINITION window displays the word BROWN in yellow characters, selecting BROWN results in a yellow item.  [cautionend]

column-header
defines the column header for the report item. Enclose each header in single or double quotation marks. When you specify multiple column headers, PROC REPORT uses a separate line for each one. The split character also splits a column header over multiple lines.

In traditional (monospace) SAS output, if the first and last characters of a header are one of the following characters, PROC REPORT uses that character to expand the header to fill the space over the column:

:- = \_ .* +

Similarly, if the first character of a header is < and the last character is >, or vice-versa, PROC REPORT expands the header to fill the space over the column by repeating the first character before the text of the header and the last character after it.
Default:

Item Header
variable without a label variable name
variable with a label variable label
statistic statistic name

Tip: If you want to use names when labels exist, submit the following SAS statement before invoking PROC REPORT:
options nolabel;
Tip: HEADLINE underlines all column headers and the spaces between them. In traditional (monospace) SAS outut, you can underline column headers without underlining the spaces between them, by using the special characters '--' as the last line of each column header instead of using HEADLINE (see Consolidating Multiple Observations into One Row of a Report ).
See also: SPLIT=
Featured in: Using Aliases to Obtain Multiple Statistics for the Same Variable , Consolidating Multiple Observations into One Row of a Report , and Creating a Column for Each Value of a Variable

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 windowing environment, you add a computed variable to a report from the COMPUTED VAR window.

In the nonwindowing environment, you add a computed variable by

Featured in: Creating a Column for Each Value of a Variable and Calculating Percentages

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 item, which must be a data set variable, as a display variable.

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, PROC REPORT tries to split text at a blank.
Restriction: This option has no effect on the HTML or Printer output.
Featured in: Calculating Percentages

FORMAT=format
assigns a SAS or user-defined format to the item. This format applies to 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:

If none of these is present, 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 windowing environment, if you are unsure what format to use, type a question mark (?) in the format field in the DEFINITION window to access the FORMATS window.
Featured in: Ordering the Rows in a Report and Displaying Multiple Statistics for One Variable

GROUP
defines item, which must be a data set variable, as a group variable. (See Group Variables .)
Featured in: Consolidating Multiple Observations into One Row of a Report , Displaying Multiple Statistics for One Variable , and Using a Format to Create Groups

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.
Featured in: Displaying Multiple Statistics for One Variable

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 a windowing 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, it searches for entry-name.HELP. If neither a CBT nor a HELP entry for the selected item exists, 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 headers over the values. If the format width is the same as the width of the column, the LEFT option has no effect on the placement of values.

NOPRINT
suppresses the display of the report item. Use this option

Interaction: 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 ).
Interaction: SHOWALL in the PROC REPORT statement or the ROPTIONS window overrides all occurrences of NOPRINT.
Featured in: Using Aliases to Obtain Multiple Statistics for the Same Variable , Writing a Customized Summary on Each Page , and Creating and Processing an Output Data Set

NOZERO
suppresses the display of the report item if its values are all zero or missing.
Interaction: 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 ).
Interaction: SHOWALL in the PROC REPORT statement or in the ROPTIONS window overrides all occurrences of NOZERO.

ORDER
defines item, which must be a data set variable, as an order variable. (See Order Variables .)
Featured in: Ordering the Rows in a Report

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. By default, the order is ascending.

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.
Featured in: Ordering the Rows in a Report
CAUTION:
Default for the ORDER= Option. In other SAS procedures, the default is ORDER=INTERNAL. The default for the option in PROC REPORT may 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 you expect even if the default changes.  [cautionend]

PAGE
inserts a page break just before printing the first column containing values of the report item.
Interaction: PAGE is ignored if you use WRAP in the PROC REPORT statement or in the ROPTIONS window.

RIGHT
right-justifies the formatted values of the specified item within the column width and right-justifies the column headers over the values. If the format width is the same as the width of the column, RIGHT has no effect on the placement of values.

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 the HTML or Printer output.
Interaction: When PROC REPORT's CENTER option is in effect, PROC REPORT ignores spacing that precedes the leftmost variable in the report.
Interaction: 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 you specify to calculate values for the analysis variable for the observations represented by each cell of the report. You cannot use statistic in the definition of any other kind of variable.
Default: SUM

Note:   PROC REPORT uses the name of the analysis variable as the default header for the column. You can customize the column header with the column-header option in the DEFINE statement.  [cautionend]
Use one of the following values for statistic:

N CSS
NMISS STDERR
MEAN CV
STD T
MIN PRT
MAX VAR
RANGE SUMWGT
SUM PCTN
USS PCTSUM

Requirement: To compute standard error and the Student's t-test you must use the default value of VARDEF= which is DF.
See also: For definitions of these statistics, see Keywords and Formulas .
Featured in: Ordering the Rows in a Report , Using Aliases to Obtain Multiple Statistics for the Same Variable , and Consolidating Multiple Observations into One Row of a Report

STYLE<(location(s))>=<style-element-name><[style-attribute-specification(s)]>
specifies the style element to use for column headers and for text inside cells for this report item.

Note:   You can use braces ({ and }) instead of square brackets ([ and ]).  [cautionend]

location
identifies the areas of the column that the STYLE= option affects. location can be

COLUMN
affects all text that is inside the cells of the table for this report item.

HEADER
affects the column header for this report item.

Default: If you do not specify a location, STYLE= affects both the column header and the text in the cells.

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 Institute provides some style definitions. Users can create their own style definitions and style elements with PROC TEMPLATE.
Default: If you do not specify a style element, PROC REPORT uses Data for the COLUMN location and Header for the HEADER location.
See also: For information about Institute-supplied style definitions, see What Style Definitions Are Shipped with the Software? .

For information about PROC TEMPLATE and the Output Delivery System, see The Complete Guide to the SAS Output Delivery System.

style-attribute-specification
describes the style attribute to change. Each style-attribute-specification has this general form:
style-attribute-name=style-attribute-value

You can set these style attributes:

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=

For information about style attributes, see What Style Attributes Can Base Procedures Specify? .

Retriction: This option affects only the HTML and Printer output.
Featured in: Specifying Style Elements for HTML Output in Multiple Statements

WIDTH=column-width
defines the width of the column in which PROC REPORT displays item.
Default: A column width that is just large enough to handle the format. If there is no format, PROC REPORT uses the value of COLWIDTH=.
Range: 1 to the value of the SAS system option LINESIZE=
Restriction: This option has no effect on the HTML or Printer output.
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.
Featured in: Calculating Percentages


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.