Example 6.5. Adding “Traffic Lighting” to a Report Created by PROC TABULATE

Goal

Customize the appearance of the report produced in the related technique of Example 3.2 by modifying style attributes with ODS. Use “traffic lighting” to draw attention to specific results in the report by setting style elements to specific colors. Send the output to a nonlisting destination.

Report

Example Features

Data SetBREAD
Report ExampleExample 3.2 Related Technique
Featured StepsPROC FORMAT PROC TABULATE
Featured Step Statements and OptionsPROC FORMAT

Assigning colors to value labels

ODS STYLE= options placed on these PROC TABULATE statements:

CLASS

CLASSLEV

TABLE, including BOX= option

KEYWORD

Output Destination of ExampleRTF
Other Examples That Use This Data SetExamples 3.2 and 6.15

Example Overview

The report in the Related Technique section of Example 3.2 shows descriptive statistics for several combinations of classifications in the BREAD data set. This example presents only the table produced by the last request in the TABLE statement. The last table request computes descriptive statistics on calories and dietary fiber for the categories defined by the combination of the values of SOURCE and BRAND.

The report in this example visually identifies the means above and below specific values by setting the background color of the cell. Formats created by PROC FORMAT associate ranges of values to colors. A format is defined for ranges of calorie values, and a format is defined for ranges of dietary fiber values. The program applies each format to the mean statistic of the specific analysis variable by setting the background style element attribute to the format name.

Program

Define formats that associate ranges of values to colors.
proc format;

Define a format to associate with the CALORIES analysis variable. Do not change the middle range’s color from the default color.
  value colorcal low-85='graycc'
                 95-high='grayee';

Define a format to associate with the DIETARY_FIBER analysis variable. Do not change the middle range’s color from the default color.
  value colorfib low-1.8='grayee'
                 2-high='graycc';

run;

Do not send results to the LISTING destination.
ods listing close;

Send subsequent results to the RTF destination and save the results in a file.
ods rtf file='c:
eportsexample32.rtf';




proc tabulate data=bread;
  title 'Nutritional Information about Breads
 Available
         in the Region';
  title2 'Values Per Bread Slice, Calories in kcal,
          Fiber in Grams';

Set the background color of the cells containing the headings for SOURCE and BRAND.
  class source brand / style={background=grayee};

Set the background color of the cells containing the levels of SOURCE and BRAND.
  classlev source brand / style={background=white};

Set the background color of the cells containing the headings for CALORIES and DIETARY_FIBER.
  var calories dietary_fiber /
               style={background=grayee};

  table source*brand,
        calories*(n*f=3.

Set the background color of the cells containing the means of CALORIES to the colors defined in the COLORCAL format.
        (mean*{style={background=colorcal.}}
         min max)*f=7.1)
         dietary_fiber*(n*f=3.

Set the background color of the cells containing the means of DIETARY_FIBER to the colors defined in the COLORFIB format.
        (mean*{style={background=colorfib.}}
         min max)*f=7.1) /

Set the background color of the PROC TABULATE upper left corner box.
        / box={style={background=white}}
        rts=30;

Set the background color of the N, MEAN, MIN, and MAX keyword headings.
  keyword n mean min max / style={background=white};
run;

Terminate sending output to the RTF destination.
ods rtf close;

Send subsequent output to the LISTING destination.
ods listing;


..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.9.164