Example 6.1. Customizing a PROC REPORT Detail Report

Goal

Customize the appearance of the report produced in Example 2.2 by modifying style attributes with ODS. Send the output to a nonlisting destination.

Report

SAS Output

Listing of Local Residential Properties Price Range $200,000 to $350,000 Listed by Zone
Residential ZoneListing PriceHouse StyleAddressBedroomsBathroomsSquare FeetAge
East Lake$329,900ranch8122 Maude Steward Rd.33.02,4002
$281,900split6424 Old Jenks Rd.31.51,22518
$260,000split4341 Rock Quarry31.01,01028
$207,900ranch650S Orchard Knoll32.01,5266
Ensley$260,000townhouse409 Galashiels21.51,2804
Inside Beltline$343,000capecod100 Cumberland Green32.51,6500
$284,000townhouse765 Crabtree Crossing32.01,4711
$279,950split101 Meadowglade Ln.32.02,0040
$279,900townhouse108Chattle Close32.52,0804
$259,900townhouse216 Concannon Ct.21.51,0409
$249,900townhouse1239 Donaldson Ct.21.51,15015
Mountain Brook$200,000duplex108 South Elm St.31.01,56973
North Ridge$344,500bungalow6008 Brass Lantern Ct.32.52,4166
$314,900colonial4000 Skipjack Ct.32.52,7500
$285,000split2414 Van Dyke31.01,24536
$282,900split500 E. Millbrook Rd.31.51,32923
$200,000split6324 Lakeland, Lake Park32.01,66212
Roebuck$323,500split110 Skylark Way32.01,97610
$286,900split5617 Laurel Crest Dr.31.51,44128
$271,000townhouse8 Stonevillage22.01,2766
Southside$202,000townhouse154 Montrose22.01,5956
Westend$278,900splitRt.5 Yarbororugh Rd. 221.09602
$217,800split603 Greentree Dr.32.01,5335
Listing Produced on Dec 10, 2005

Example Features

Data SetHOUSING
Report ExampleExample 2.2
Featured StepPROC REPORT
Featured Step Statements and OptionsPROC REPORT statement ODS options: STYLE(HEADER)=, and

STYLE(REPORT)=

DEFINE statement ODS options: STYLE(COLUMN)= and STYLE(HEADER)
Output Destination of ExampleHTML
A Closer LookUnderstanding PROC REPORT ODS Options Placing STYLE= Options in a PROC REPORT Step
Other Examples That Use This Data SetExamples 2.1 and 2.2

Example Overview

The report in Example 2.2 lists selected observations in the HOUSING data set in a specific order. When sending the report to a destination other than the LISTING destination, you can further customize the report by changing style attributes in specific locations of the report.

This example sends the same report to an HTML destination. The program overrides some of the style attributes in the current style definition in three locations in the report: the overall report, the heading, and specific columns.

Program

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

Send subsequent results to the HTML destination and save the results in a file.
ods html file='c:
eportsexample22.html';


proc report data=housing nowindows split='/'

Override existing style attributes in specific locations of the report. Apply style changes to the overall report. Insert rules between the rows in the table produced by PROC REPORT. Do not put any space between the cells. (This suppresses the appearance of background color between the cells if the background color is different from the cell border color.)
            style(report)={rules=rows cellspacing=0}

Italicize all column headings in the report.
           style(header)={font_style=italic};


   title 'Listing of Local Residential Properties';
   title2 'Price Range $200,000 to $350,000';
   title3 'Listed by Zone';

   footnote "Listing Produced on
             %sysfunc(today(),worddate12.)";

   where price between 200000 and 350000;

   column zone price type address bedr bath sqfeet
 age;

   define  zone    / order format=$zonefmt15. width=15
                     'Residential/Zone'

Write all values in the ZONE column in bold.
                     style(column)={font_weight=bold};
   define  price   / order descending format=dollar10.
                     width=10 'Listing/Price';

   define  type    / display format=$9.'House/Style';

   define  address / format=$25. width=25 'Address'

Left justify the heading for the ADDRESS column.
                     style(header)={just=left};

Center the contents of the BEDR and BATH columns.
   define  bedr    / format=2. width=8 'Bedrooms'
                     style(column)={just=center};
   define  bath    / format=3.1 width=9 'Bathrooms'
                     style(column)={just=center};
   define  sqfeet  / format=comma6. width=6
                     'Square/Feet';
   define  age     / format=3. 'Age';

run;

Terminate sending output to the HTML destination.
ods html close;

Send subsequent output to the LISTING destination.
ods listing;


A Closer Look

Understanding PROC REPORT ODS Options

PROC REPORT ignores options such as line spacing and underlining when instructed to send your report to a nonlisting destination. Conversely, the style attributes that you modify for a nonlisting destination are ignored if instead you send the output to the LISTING destination.

The PROC REPORT statement options HEADLINE and SPACING= were removed from Example 2.2 because of their application only to the LISTING destination.

This example’s program also does not include the BREAK AFTER statement because its only function is to skip a line between zones. PROC REPORT ignores the SKIP option when sending the output to a nonlisting destination. If you still want a space between zones in such a report, you could write a COMPUTE AFTER block and a LINE statement similar to the one that follows:

   compute after zone;
     line ' ';
   endcomp;

The following PROC REPORT statement options are ignored when you send your report to a nonlisting destination:

BOX         COLWIDTH=    FORMCHAR=    HEADLINE      HEADSKIP
LINESIZE=   PANELS=      PSPACE=      SPACING=

The following options on the BREAK and RBREAK statements are ignored when you send your report to a nonlisting destination:

DOL         OL           UL           DUL           SKIP

Placing STYLE= Options in a PROC REPORT Step

When you send your PROC REPORT report to a nonlisting destination, you can take advantage of the formatting capabilities of the destination by customizing style elements in the report. You can do this either by using STYLE= options in PROC REPORT or by defining a style and referencing it on the ODS destination statement.

Modifying style attributes in a PROC REPORT step makes changes only to the report in which the modifications are applied. If you want to modify the output the same way repeatedly, you might find it more efficient to define and save a style rather than to code the same style attributes every time you execute a report. Examples 6.12, 6.14 and 6.15 define styles and table definitions for that purpose.

The remainder of this section discusses how to use STYLE= options in PROC REPORT. The syntax of the STYLE= option is

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

Table 6.1a lists the report locations where style elements can be modified with the STYLE= option. It also lists the statements where the STYLE= option can be placed.

Table 6.1a. Locations in PROC REPORT Where Style Elements Can Be Modified with the STYLE= Option
LocationOption SpecificationStatements Where STYLE= Option Can Be Included
Column cellsSTYLE(COLUMN)PROC REPORT DEFINE
Column headerSTYLE(HEADER)PROC REPORT DEFINE
Entire reportSTYLE(REPORT)PROC REPORT
Lines generated by summariesSTYLE(SUMMARY)PROC REPORT

BREAK

RBREAK
Lines written by LINE statements in COMPUTE blocksSTYLE(LINES)PROC REPORT COMPUTE
Cells identified by a CALL DEFINE statementSTYLE(CALLDEF)PROC REPORT CALL DEFINE

Each statement has a default location and style element as shown in Table 6.1b. For example, if you omit the location on a STYLE= option placed on a DEFINE statement and specify an attribute for the style element “font_style,” both the data and header for the column are modified according to the attribute assigned to “font_style.”

Table 6.1b. Locations and Default Style Elements for Each Statement in PROC REPORT
StatementValid Location ValuesDefault Location ValueDefault Style Element
PROC REPORTREPORT, COLUMN, HEADER, SUMMARY, LINES, CALLDEFREPORTTable
BREAKSUMMARY, LINESSUMMARYData Emphasis
CALL DEFINECALLDEFCALLDEFData
COMPUTELINESLINESNoteContent
DEFINECOLUMN, HEADERCOLUMN and HEADERCOLUMN: Data HEADER: Header
RBREAKSUMMARY, LINESSUMMARYData Emphasis

Unless you modify an attribute with a STYLE= option, PROC REPORT uses the style element attributes in the style definition that are in effect at the time PROC REPORT executes. This will be your system’s default style definition unless you specify a different style on the ODS statement that processes the output from PROC REPORT.

The STYLE= options that you code on your PROC REPORT statement affect all associated locations in the report. STYLE= options placed on specific statements override the same named style element attributes placed on the PROC REPORT statement. For example, STYLE= options that you place on a DEFINE statement override the attributes specified on the PROC REPORT statement for the column that the DEFINE statement defines.

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

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