Previous Page | Next Page

The PRINT Procedure

Example 3: Creating Separate Sections of a Report for Groups of Observations


Procedure features:

PROC PRINT statement options:

LABEL

N=

NOOBS

STYLE

BY statement

PAGEBY statement

Other features:

SORT procedure

FORMAT statement

LABEL statement

ODS RTF statement

TITLE statement

Data set: EXPREV

This example


Program: Creating a Listing Report

 Note about code
options nodate pageno=1 linesize=80 pagesize=40 obs=10;
 Note about code
proc sort data=exprev;
   by sale_type order_date quantity;
run;
 Note about code
proc print data=exprev n='Number of observations for the month: ' 
           noobs label;
 Note about code
   var quantity cost price;
 Note about code
   by sale_type order_date;
   pageby order_date;
 Note about code
   label sale_type='Order Type' order_date='Order Date';
 Note about code
   format price dollar7.2 cost dollar7.2;
   title 'Prices and Cost Grouped by Date and Order Type';
   title2 'in USD';
run;

Output: Listing

Creating Separate Sections of a Report for Groups of Observations: Listing Output

                 Prices and Cost Grouped by Date and Order Type                1
                                     in USD

--------------------- Order Type=Catalog Order Date=1/1/08 ---------------------

                         Quantity       Cost      Price

                             7         $9.25     $41.00
                             8        $28.45    $113.40
                            14        $12.10     $51.20
                            30        $59.00    $123.70

                    Number of observations for the month: 4
                 Prices and Cost Grouped by Date and Order Type                2
                                     in USD

--------------------- Order Type=Catalog Order Date=1/2/08 ---------------------

                         Quantity       Cost      Price

                             11       $20.20     $40.20
                            100        $5.00     $11.80

                    Number of observations for the month: 2
                 Prices and Cost Grouped by Date and Order Type                3
                                     in USD

-------------------- Order Type=In Store Order Date=1/1/08 ---------------------

                         Quantity       Cost      Price

                            25        $15.65     $31.10

                    Number of observations for the month: 1
                 Prices and Cost Grouped by Date and Order Type                4
                                     in USD

-------------------- Order Type=In Store Order Date=1/2/08 ---------------------

                         Quantity       Cost      Price

                             2        $36.70    $146.40
                            20        $32.30     $71.00

                    Number of observations for the month: 2
                 Prices and Cost Grouped by Date and Order Type                5
                                     in USD

-------------------- Order Type=Internet Order Date=1/1/08 ---------------------

                         Quantity       Cost      Price

                             2        $20.70     $92.60

                    Number of observations for the month: 1

Program: Creating an RTF Report

options nodate pageno=1 linesize=80 pagesize=40 obs=10;

 Note about code
ods rtf file='your_file.rtf' startpage=no;
proc sort data=exprev;
   by sale_type order_date quantity;
run;

proc print data=exprev n='Number of observations for each order type:'         
           noobs label;
   var quantity cost price;
   by sale_type order_date;    
   pageby order_date;
   label sale_type='Order Type' order_date='Order Date';
   format price dollar7.2 cost dollar7.2;    
   title 'Price and Cost Grouped by Date and Order Type';
   title2 'in USD';
run;

 Note about code
ods rtf close;

Output: RTF

Creating Separate Sections of a Report for Groups of Observations: Default RTF Output

[Creating Separate Sections of a Report for Groups of Observations: Default RTF Output]


Program: Creating an RTF Report with the STYLE Option

options nodate pageno=1 linesize=80 pagesize=40 obs=10;

ods rtf file='your_file.rtf' startpage=no;

proc sort data=exprev;
by sale_type order_date quantity;
run;

 Note about code
proc print data=exprev n='Number of observations for the month: '        
           noobs label style(N) = {background = gray};

   var quantity / style(header) = [background = white];
   var cost / style(header) = [background = blue foreground = white];
   var price / style(header) = [background = gray];      
   by sale_type order_date;    
   pageby order_date;
   label sale_type='Order Type' order_date='Order Date';
   format price dollar7.2 cost dollar7.2;   

title 'Prices and Cost Grouped by Date and Order Type';
title2 '*prices in USD';
run;
ods rtf close;


Output: RTF with Styles

Creating Separate Sections of a Report for Groups of Observations: RTF Output Using Styles

[Prices and Cost Grouped by Date and Order Type]

Previous Page | Next Page | Top of Page