Base SAS 9.1 Procedures Guide, Volumes 1, 2, 3 and 4

Tip: Supports the Output Delivery System. See Output Delivery System on page 32 for details.

ODS Table Name : Print

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 PRINT < option(s) >;

To do this

Use this statement

Produce a separate section of the report for each BY group

BY

Identify observations by the formatted values of the variables that you list instead of by observation numbers

ID

Control page ejects that occur before a page is full

PAGEBY

Limit the number of sums that appear in the report

SUMBY

Total values of numeric variables

SUM

Select variables that appear in the report and determine their order

VAR

PROC PRINT Statement

PROC PRINT < option(s) >;

To do this

Use this option

Specify text for the HTML contents link to the output

CONTENTS=

Specify the input data set

DATA=

Control general format

 
 

Write a blank line between observations

DOUBLE

 

Print the number of observations in the data set, in BY groups, or both, and specify explanatory text to print with the number

N=

 

Suppress the column in the output that identifies each observation by number

NOOBS

 

Specify a column header for the column that identifies each observation by number

OBS=

 

Round unformatted numeric values to two decimal places

ROUND

Control page format

 
 

Format the rows on a page

ROWS=

 

Use each variable s formatted width as its column width on all pages

WIDTH=UNIFORM

Control column format

 
 

Control the orientation of the column headings

HEADING=

 

Use variables labels as column headings

LABEL or SPLIT=

 

Specify the split character, which controls line breaks in column headings

SPLIT=

 

Specify one or more style elements for the Output Delivery System to use for different parts of the report

STYLE

 

Determine the column width for each variable

WIDTH=

Options

CONTENTS= link-text

DATA= SAS-data-set

DOUBLE

HEADING= direction

LABEL

N<= string-1 < string-2 >>

NOOBS

OBS= column-header

ROUND

ROWS= page-format

SPLIT= split-character

STYLE

<( location(s) )>=< style-element-name ><[ style-attribute-specification(s) ]>

Table 35.1: Specifying Locations in the STYLE Option

This location

Affects this part of the report

And can also be specified for individual items in this statement

BYLABEL

the label for the BY variable on the line containing the SUM totals

none

DATA

the cells of all columns

VAR

ID

SUM

GRANDTOTAL

the SUM line containing the grand totals for the whole report

SUM

HEADER

all column headers

VAR

ID

SUM

N

N= table and contents

none

OBS

the data in the OBS column

none

OBSHEADER

the header of the OBS column

none

TABLE

the structural part of the report - that is, the underlying table used to set things like the width of the border and the space between cells

none

TOTAL

the SUM line containing totals for each BY group

SUM

For your convenience and for consistency with other procedures, the following table shows aliases for the different locations.

Table 35.2: Aliases for Locations

Location

Aliases

BYLABEL

BYSUMLABEL

BYLBL

BYSUMLBL

DATA

COLUMN

COL

GRANDTOTAL

GRANDTOT

GRAND

GTOTAL

GTOT

HEADER

HEAD

HDR

N

none

OBS

OBSDATA

OBSCOLUMN

OBSCOL

OBSHEADER

OBSHEAD

OBSHDR

TABLE

REPORT

TOTAL

TOT

BYSUMLINE

BYLINE

BYSUM

Table 35.3: The Default Style Element for Each Location in PROC PRINT

Location

Default style element

BYLABEL

Header

DATA

Data (for all but ID statement)

RowHeader (for ID statement)

GRANDTOTAL

Header

HEADER

Header

N

NoteContent

OBS

RowHeader

OBSHEADER

Header

TABLE

Table

TOTAL

Header

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, 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.

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=

UNIFORM

WIDTH= column-width

BY Statement

Produces a separate section of the report for each BY group.

Main discussion: BY on page 58

Featured in: Example 3 on page 747, Example 4 on page 753, Example 5 on page 758, Example 6 on page 764, and Example 8 on page 776

BY <DESCENDING> variable-1

Required Arguments

variable

Options

DESCENDING

NOTSORTED

Using the BY Statement with an ID Statement

PROC PRINT uses a special layout if all BY variables appear in the same order at the beginning of the ID statement. (See Example 8 on page 776.)

Using the BY Statement with the NOBYLINE Option

If you use the BY statement with the SAS system option NOBYLINE, which suppresses the BY line that normally appears in output produced with BY-group processing, PROC PRINT always starts a new page for each BY group. This behavior ensures that if you create customized BY lines by putting BY-group information in the title and suppressing the default BY lines with NOBYLINE, the information in the titles matches the report on the pages.

ID Statement

Identifies observations by using the formatted values of the variables that you list instead of by using observation numbers.

Featured in: Example 7 on page 769 and Example 8 on page 776

ID variable(s) </ STYLE <( location(s) )>

Required Arguments

variable(s)

Options

STYLE <( location(s) )>=< style-element-name ><[ style-attribute-specification(s) ]>

Using the BY Statement with an ID Statement

PROC PRINT uses a special layout if all BY variables appear in the same order at the beginning of the ID statement. (See Example 8 on page 776.)

PAGEBY Statement

Controls page ejects that occur before a page is full.

Requirements: BY statement

Featured in: Example 3 on page 747

PAGEBY BY-variable ;

Required Arguments

BY-variable

SUM Statement

Totals values of numeric variables.

Featured in: Example 4 on page 753, Example 5 on page 758, Example 6 on page 764, and Example 8 on page 776

SUM variable(s) </ STYLE <( location(s) )>

Required Arguments

variable(s)

Option

STYLE <( location(s) )>=< style-element-name ><[ style-attribute-specification(s) ]>

Using the SUM and BY Statements Together

When you use a SUM statement and a BY statement with one BY variable, PROC PRINT sums the SUM variables for each BY group that contains more than one observation and totals them over all BY groups (see Example 4 on page 753).

When you use a SUM statement and a BY statement with multiple BY variables, PROC PRINT sums the SUM variables for each BY group that contains more than one observation, just as it does if you use only one BY variable. However, it provides sums only for those BY variables whose values change when the BY group changes. (See Example 5 on page 758.)

Note: When the value of a BY variable changes, the SAS System considers that the values of all variables listed after it in the BY statement also change.

SUMBY Statement

Limits the number of sums that appear in the report.

Requirements: BY statement

Featured in: Example 6 on page 764

SUMBY BY-variable ;

Required Arguments

BY-variable

What Variables Are Summed?

If you use a SUM statement, PROC PRINT subtotals only the SUM variables. Otherwise, PROC PRINT subtotals all the numeric variables in the data set except those listed in the ID and BY statements.

VAR Statement

Selects variables that appear in the report and determines their order.

Tip: If you omit the VAR statement, PROC PRINT prints all variables in the data set.

Featured in: Example 1 on page 739 and Example 8 on page 776

VAR variable(s) </ STYLE <( location(s) )>

Required Arguments

variable(s)

Option

STYLE <( location(s) )>=< style-element-name ><[ style-attribute-specification(s) ]>

Категории