Example 6.6. Including Images in a Report Created by PROC REPORT

Goal

Add images to the report produced in Example 6.2. Send the output to a non-listing destination.

Report

Example Features

Data SetCARSALES
Report ExampleExample 6.2, which was based on Example 3.8
Featured StepPROC REPORT
Featured Step Statements and OptionsPROC REPORT statement ODS options: STYLE(LINES)=, STYLE(SUMMARY)=, and STYLE (REPORT)= with PREIMAGE style attribute

DEFINE statement ODS options: STYLE(COLUMN)=

COMPUTE BEFORE _PAGE_ block, ODS STYLE= option: PREIMAGE style attribute

COMPUTE AFTER _PAGE_ block, ODS STYLE= option: POSTMAGE style attribute
Output Destination of ExampleRTF
Other Examples That Use This Data SetExamples 3.8 and 6.2

The program in this example modifies the report presented in Example 6.2. It adds two images at the beginning of the report and one at the end.

You can include images in your report at specific locations by adding style attributes that reference images. The images in this example are saved in JPEG files.

Program

Clear any existing titles and footnotes. The display of title and footnote information will be handled by the COMPUTE BEFORE _PAGE_ and COMPUTE AFTER _PAGE_ blocks in PROC REPORT.
title;
footnote;

Define the MNTHFMT format as in Example 3.8.
proc format;
   value mnthfmt 1-3 = '1st'
                 4-6 = '2nd'
                 7-9 = '3rd'
               10-12 = '4th';
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:
eportsexample38a.rtf';

Lengthen the variable NAME so that the summary line label can be completely inserted into NAME.
data carsales;
  length name $ 50;
  set carsales;
run;

Maintain the same style element attributes for SUMMARY and LINES as in Example 6.2.
proc report data=carsales nowindows
            style(summary)={font_weight=bold}
            style(lines)={font_weight=bold
                          font_style=italic
                          just=center}

Place an image before the table. Identify the path and name of the image file.
                 style(report)=
                      {preimage='c:
eports
vroomsales.jpg'};

Maintain the same code from the COLUMN statement through the COMPUTE AFTER block as in Example 6.2.
  column name month numsold amtsold avgsales maxsales;

  define name     / group 'Sales/Representative'
                    style(column)={font_weight=bold};
  define month    / group 'Quarter' center
                    format=mnthfmt.;

  define numsold  / analysis sum 'Cars Sold/by
/Quarter'
                    format=2.;
  define amtsold  / analysis sum
                    'Total Sales/by/Quarter'
                    format=dollar13.2;

  define avgsales / computed 'Average/Sale'
                    format=dollar13.2;

  define maxsales / computed noprint;


  compute before name;
    bigsales=0;
    bigqtr=50;
  endcomp;

  compute avgsales;
     avgsales = amtsold.sum / numsold.sum;
  endcomp;

  compute maxsales;
    if _break_=' ' and bigsales lt amtsold.sum
 then do;
      bigsales=amtsold.sum;
      bigqtr=month;
    end;
  endcomp;

  break after name / summarize;

  compute after name;
    length fullline $ 50;
    fullline=catx(' ','Best Quarter for',
                  cats(name,':'),
                  put(bigqtr,mnthfmt.));

    name=catx(' ','Sales Totals for ',name);

    line fullline $50.;
  endcomp;

  rbreak after / summarize;

  compute after;
    name='Annual Totals';
  endcomp;

Insert an image in the space between the titles and the column headings, which is referenced with the keyword _PAGE_.
    compute before _page_ /
                   style={preimage='c:
eportsqmc
.jpg'};

Include the LINE statement even though it writes only a space, because without a LINE statement, the preimage would not be displayed.
    line ' ';
  endcomp;

Insert an image in the space between the last row of the report and the end of the report, which is referenced with the keyword _PAGE_.
  compute after _page_ /
              style={postimage='c:
eports
keepselling.jpg'};

Include the LINE statement even though it writes a space, because without a LINE statement, the postimage would not be displayed.
    line ' ';
  endcomp;
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.145.9.12