Using Style Elements in the REPORT and TABULATE ... - SAS

[Pages:28]Technical Paper

Using Style Elements in the REPORT and TABULATE Procedures

Using Style Elements in the REPORT and TABULATE Procedures

Table of Contents

Introduction ....................................................................................................................1 STYLE= Option: Syntax and General Description ......................................................1 Using Styles in the REPORT Procedure ......................................................................2

Using Styles in the DEFINE Statement .....................................................................3 Using Styles in the BREAK and RBREAK Statements .............................................5 Using Styles in the COMPUTE Statement ................................................................7 Styles in a CALL DEFINE Statement ........................................................................8 Styles in the TABULATE Procedure...........................................................................10 Styles in the CLASS, VAR, and KEYWORD Statements........................................11 Styles in the CLASSLEV Statement ........................................................................13 Styles in the PROC TABULATE Statement ............................................................14 Styles Used to Change Gridlines.............................................................................15 Multiple Styles in the TABLE Statement..................................................................16 Inherited Attributes for a Column.............................................................................17 Inherited Attributes for a Row ..................................................................................18 URL Addresses and Images....................................................................................20 Conclusion ....................................................................................................................21 References ....................................................................................................................22

i

Using Style Elements in the REPORT and TABULATE Procedures

Introduction

When you invoke the SAS? Output Delivery System (ODS) to generate output, the application uses a default style. Yet, users often find that they need to customize their output even more. With many SAS procedures, you can use the TEMPLATE procedure to modify your output. However, for a few procedures, such as the REPORT procedure and the TABULATE procedure, the output cannot be fully modified using PROC TEMPLATE. You can create customized ODS output with PROC REPORT and PROC TABULATE by using the STYLE= option directly in the procedures. Knowing which option to use in order to change the attribute of a particular item in the output report can be a challenge. This paper addresses this challenge and illustrates how to use the STYLE= option in the REPORT and TABULATE procedures to customize output.

STYLE= Option: Syntax and General Description

The STYLE= option enables you to specify style (presentation) elements for various parts of a report. The syntax for the STYLE= option follows:

STYLE= Note: You can use braces instead of the square brackets around the style attribute specifications.

STYLE= The STYLE= option uses six different location values to identify the part of the report that the option affects. The location values and their associated default style elements follow:

? REPORT--Denotes the structural, or underlying, part of the report. Default style element: Table ? COLUMN--Denotes the cells in all the columns. Default style element: Data ? HEADER--Denotes all column headers, including spanned headers. Default style element: Header ? SUMMARY--Denotes all of the default summary lines that are produced by a BREAK or an RBREAK statement.

Default style element: DataEmphasis ? LINES--Denotes all LINE statements in all COMPUTE blocks. Default style element: NoteContent ? CALLDEF--Denotes all cells that are identified by a CALL DEFINE statement. Default style element: Data

If a location value is not specified in the STYLE= option, ODS defaults to the REPORT value.

1

Using Style Elements in the REPORT and TABULATE Procedures

Using Styles in the REPORT Procedure

In the REPORT procedure, the PROC REPORT statement is the highest level at which you can request styles. The following example illustrates the use of the six STYLE= location values in the PROC REPORT statement:

ods html file='my-file.htm'; proc report nowd data=sashelp.class(obs=2)

style(report)=[background=green cellspacing=10] style(column)=[background=yellow] style(header)=[background=pink] style(summary)=[background=lightblue] style(lines)=[background=white] style(calldef)=[background=purple]; col name age weight height; define age / order; break after age / summarize; compute weight; if weight.sum > 100 then call define ('weight.sum','style','style=[foreground=orange

font_weight=bold]'); endcomp; compute after age;

name='Total'; line ' '; endcomp; run; ods html close; Without the instances of the STYLE= option in the PROC REPORT statement, ODS generates the following default output:

Output 1. Default Output without the STYLE= Option 2

Using Style Elements in the REPORT and TABULATE Procedures With the six instances of the STYLE= option, ODS generates the following output:

Output 2. Output Generated with the STYLE= Option In this example, all six locations in the report have a background color change. Note the cell-spacing attribute in the STYLE= option that specifies the report location. This attribute enhances the report further by designating the amount of space, in points (CELLSPACING=10), between cells. You should also be aware that you cannot specify STYLE(CALLDEF) unless you have a CALL DEFINE statement in the code.

Using Styles in the DEFINE Statement

In PROC REPORT, the DEFINE statement enables you to specify styles for the column or header locations for an individual variable. If no location value is listed in the DEFINE statement, the default location value is HEADER. In the DEFINE statement:

? Styles that are specified in a DEFINE statement override the styles that are listed in the PROC REPORT statement. ? The specification STYLE(COLUMN)= applies to the entire column. ? The specification STYLE(HEADER)= applies to the header. ? The specification STYLE(COLUMN HEADER) applies to both locations. The following example illustrates the use of the STYLE= option in DEFINE statement.

proc format; value colorme 1='white' 2='purple';

3

Using Style Elements in the REPORT and TABULATE Procedures

data flower; input row cols $ value; cards;

1 a 1 1 b 2 1 c 1 1 d 2 2 a 2 2 b 1 2 c 2 2 d 1 3 a 1 3 b 2 3 c 1 3 d 2 4 a 2 4 b 1 4 c 2 4 d 1 ; run;

ods html file='my-file.htm';

proc report nowd data=flower style=[cellwidth=.1in rules=group frame=void] style(column header)=[background=yellow foreground=blue];

col row cols , value; define row / group ' '

style(column header)=[foreground=green background=green]; define value /

style(column)=[background=colorme. foreground=colorme.] ' '; define cols / across

style(header)=[foreground=green background=green] ' '; run;

ods html close;

Without the STYLE= option in the DEFINE statements, ODS generates the following output:

Output 3. Output Generated without the STYLE= Option in the DEFINE Statement

4

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download