Example 6.8. Presenting Graphics and Tables in the Same Report

Goal

Describe data visually in graphs and numerically in tables in the same report. Add graphs to the report in Example 3.3. Send the output to a nonlisting destination.

Report

Example Features

Data SetLIPIDS
Report ExampleExample 3.3
Featured Steps and StatementPROC UNIVARIATE

PROC TABULATE

ODS statement
Featured Step Statements and OptionsODS statement: STARTPAGE= option

PROC UNIVARIATE

PROC UNIVARIATE statement: NOPRINT option

CLASS statement: (ORDER=) option

HISTOGRAM statement

HISTOGRAM statement: NORMAL(NOPRINT COLOR=), FONT=, HREF=, MIDPOINTS=, and HREFLABELS= options

ODS STYLE= options placed on these PROC TABULATE statements:

CLASS

CLASSLEV

KEYWORD

TABLE, including BOX= option

VAR

Output Destination of ExampleRTF
A Closer LookSummarizing Data in Graphs
Other Examples That Use This Data SetExamples 2.7, 3.3, 6.4, and 6.9

Example Overview

Example 3.3 statistically summarizes the three lipid measurements in the LIPIDS data set. It presents the descriptive statistics for the categories defined by testing period and for those defined by the combination of testing period and gender.

This example includes histograms of the cholesterol measurements for the categories defined by testing period and gender, as well as the table of statistics. The graphs are placed before the table and are generated by PROC UNIVARIATE.

Style attributes for the background are added to components of the PROC TABULATE table.

The ODS option STARTPAGE=NO causes the table to follow the graphs on the same page. Example 6.13 also uses the STARTPAGE= option on the ODS statement and includes a discussion of its usage.

The RTF file created by this program contains the histograms and the table of statistics. The four histograms are treated as one picture in the RTF file, and the title specified on the TITLE statement is included in the picture, not in the RTF header.

Program

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:
eportsexample33b.rtf'

Suppress the automatic insertion of new pages at the start of each procedure.
        startpage=no;



proc format;

Define this format with a blank space before the text “Males” so that when the data is ordered by the formatted value, the results for males display before those for females.
  value $gender 'M'=' Males'
                'F'='Females';






  value $prepost 'Pre'='Pre Exercise Results'
                 'Post'='Post Exercise Results';
run;

title 'Exercise Program Results';
proc univariate data=lipids

Suppress all tables of descriptive statistics.
                 noprint;

Group the data into categories defined by the value of the two CLASS variables. Order the results for GENDER by its formatted values.
   class gender (order=formatted)

Order the results for TESTPERIOD by the order of its values in the data set. This will put the values for the “PRE” testing period ahead of the values for the “POST” testing period, because the first observation in the data set contains data for the “PRE” testing period. If you have reordered the observations in the LIPIDS data set, you might need to modify this option or define a format for testing period that is similar to the $GENDER format, with a blank space preceding the text “Pre Exercise Results”.
          testperiod (order=data);

Specify the analysis variable.
   var chol;
   label chol='Cholesterol';

Create a histogram for each combination of the CLASS variables and specify characteristics of the graphs.
   histogram /

Superimpose a normal density curve on each histogram. Suppress the tables that summarize the fitted curves. Specify the color of the normal density curve.
              normal(noprint color=black)

Specify the font for reference lines and axis labels.
              font=swiss

Specify the midpoints of the histogram intervals.
              midpoints=125 to 300 by 25

Display a horizontal reference line at 200 and label the line.
              href=200 hreflabels='200';


   format gender $gender. testperiod $prepost.;
 run;

 proc tabulate data=lipids;
   class gender testperiod / descending

Set the background color of the class variable name headings.
                             style={background=white};

Set the background color of the class-level value headings.
   classlev gender testperiod /
            style={background=white};

Set the background color of the analysis variable name headings.
  var chol hdl tri / style={background=white};


  table (gender='Gender'
        all='Both Genders')*testperiod='Testing
                                         Period',
        all='Lipid Profile'*(chol='Cholesterol'
        hdl='HDL' tri='Triglycerides')*
       (n*f=3. (mean std='Std Dev' p25 p50 p75)*f=5.1)

        / nocontinued

Set the background color of the box in the upper left corner of the table.
        box={style={background=white}};


 keyword all n mean std p25 p50 p75

Set the background color of the keyword headings.
          / style={background=white};


  format gender $gender.;
run;

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

Send subsequent output to the LISTING destination.
ods listing;


A Closer Look

Summarizing Data in Graphs

The examples in this book concentrate on producing text-based tables. Some images are included in the text reports in this chapter, but only this example includes a programmatically derived graphical report.

A picture can be invaluable in conveying results. When you combine both pictures and text in a report, you can help your audience better understand your results.

This example applies some of the graphing capabilities of PROC UNIVARIATE. SAS/GRAPH provides the tools and foundation for producing many types of graphical reports. Other SAS products also include procedures that display your data in a graphical format.

While plotting data is beyond the scope of this book, do not ignore this topic. The reference for presenting data graphically is SAS/GRAPH 9.1 Reference. SAS Press has several titles related to this topic. See the back of this book for a list of titles related to the features of this example, and visit the SAS Press Web site (support.sas.com/saspress) for current information on new and revised publications.

Several presentations at SUGI conferences show how SAS users have applied SAS graphical procedures. Recent conference proceedings that are available online through the SAS Web site provide a wealth of additional applications and examples to get you started in this form of report writing. You can link to them through the SAS support Web site (support.sas.com).

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

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