Previous Page | Next Page

The REPORT Procedure

Example 7: Storing and Reusing a Report Definition


Procedure features:

PROC REPORT statement options:

NAMED

OUTREPT=

REPORT=

WRAP

Other features:

TITLE statement

WHERE statement

Data set: GROCERY
Formats: $SCTRFMT., $MGRFMT. and $DEPTFMT.

The first PROC REPORT step in this example creates a report that displays one value from each column of the report, using two rows to do so, before displaying another value from the first column. (By default, PROC REPORT displays values for only as many columns as it can fit on one page. It fills a page with values for these columns before starting to display values for the remaining columns on the next page.)

Each item in the report is identified in the body of the report rather than in a column heading.

The report definition created by the first PROC REPORT step is stored in a catalog entry. The second PROC REPORT step uses it to create a similar report for a different sector of the city.


Program to Store a Report Definition

 Note about code
libname proclib 'SAS-library';
 Note about code
options nodate pageno=1 linesize=80 pagesize=60
        fmtsearch=(proclib);
 Note about code
proc report data=grocery nowd
            named
            wrap
            ls=64 ps=36
            outrept=proclib.reports.namewrap;
 Note about code
   column sector manager department sales;
 Note about code
   define sector / format=$sctrfmt.;
   define manager / format=$mgrfmt.;
   define department / format=$deptfmt.;
   define sales / format=dollar11.2;
 Note about code
   where manager='1';
 Note about code
   title "Sales Figures for Smith on &sysdate";
run;

Output

 Note about figure
               Sales Figures for Smith on 04JAN02              1

    Sector=Southeast  Manager=Smith    Department=Paper     
    Sales=     $50.00                                       
    Sector=Southeast  Manager=Smith    Department=Meat/Dairy
    Sales=    $100.00                                       
    Sector=Southeast  Manager=Smith    Department=Canned    
    Sales=    $120.00                                       
    Sector=Southeast  Manager=Smith    Department=Produce   
    Sales=     $80.00                                       

Program to Use a Report Definition

 Note about code
options nodate pageno=1 fmtsearch=(proclib);
 Note about code
 proc report data=grocery report=proclib.reports.namewrap
            nowd;
   where sector='sw';
   title "Sales Figures for the Southwest Sector on &sysdate";
run;

Output

       Sales Figures for the Southwest Sector on 04JAN02       1

    Sector=Southwest  Manager=Taylor   Department=Paper     
    Sector=Southwest  Manager=Taylor   Department=Meat/Dairy
    Sector=Southwest  Manager=Taylor   Department=Canned    
    Sector=Southwest  Manager=Taylor   Department=Produce   
    Sector=Southwest  Manager=Adams    Department=Paper     
    Sector=Southwest  Manager=Adams    Department=Meat/Dairy
    Sector=Southwest  Manager=Adams    Department=Canned    
    Sector=Southwest  Manager=Adams    Department=Produce   
       Sales Figures for the Southwest Sector on 04JAN02       2

                       Sales=     $53.00
                       Sales=    $130.00
                       Sales=    $120.00
                       Sales=     $50.00
                       Sales=     $40.00
                       Sales=    $350.00
                       Sales=    $225.00
                       Sales=     $80.00

Previous Page | Next Page | Top of Page