Previous Page | Next Page

The PRINT Procedure

Example 4: Summing Numeric Variables with One BY Group


Procedure features:

PROC PRINT statement options:

N=

SUMLABEL

BY statement

SUM statement

Other features:

ODS CSVALL statement

SORT procedure

TITLE statement

#BYVAL specification

SAS system options:

BYLINE

NOBYLINE

Data set: EXPREV

This example


Program: Creating a Listing Report

 Note about code
options nodate pageno=1 linesize=80 pagesize=40 obs=10 nobyline;
 Note about code
proc sort data=exprev;
   by sale_type;
run;
 Note about code
proc print data=exprev noobs label sumlabel
           n='Number of observations for the order type: '
          'Number of observations for the data set: ';
 Note about code
   var country order_date quantity price;
 Note about code
   label  sale_type='Sale Type'
          price='Total Retail Price* in USD'
          country='Country' order_date='Date' quantity='Quantity';
 Note about code
   sum price quantity;
   by sale_type;
 Note about code
   format price dollar7.2;
 Note about code
   title 'Retail and Quantity Totals for #byval(sale_type) Sales';
run;
 Note about code
options byline;

Output: Listing

                  Retail and Quantity Totals for Catalog Sales                 1

                                                              Total
                                                             Retail
                                                             Price*
            Country                    Date     Quantity     in USD

            Puerto Rico               1/1/08        14       $51.20
            Aruba                     1/1/08        30      $123.70
            Bahamas                   1/1/08         8      $113.40
            Bermuda                   1/1/08         7       $41.00
            British Virgin Islands    1/2/08        11       $40.20
            Canada                    1/2/08       100       $11.80
            ----------------------              --------    -------
            Sale Type                              170      $381.30

                  Number of observations for the order type: 6
                 Retail and Quantity Totals for In Store Sales                 2

                                                              Total
                                                             Retail
                                                             Price*
             Country                   Date     Quantity     in USD

             Virgin Islands (U.S.)    1/1/08       25        $31.10
             Belize                   1/2/08        2       $146.40
             Cayman Islands           1/2/08       20        $71.00
             ---------------------              --------    -------
             Sale Type                             47       $248.50

                  Number of observations for the order type: 3
                 Retail and Quantity Totals for Internet Sales                 3

                                                        Total
                                                       Retail
                                                       Price*
                   Country       Date     Quantity     in USD

                  Antarctica    1/1/08         2       $92.60
                                          ========    =======
                                             219      $722.40

Number of observations for the order type: 1
  Number of observations for the data set: 10

Program: Creating a CSV File

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

 Note about code
ods csvall file='your_file.csv';
proc sort data=exprev;
   by sale_type;
run;

proc print data=exprev noobs label sumlabel
           n='Number of observations for the order type: '
          'Number of observations for the data set: ';

var country order_date quantity price;

   label  price='Total Retail Price* in USD'
          country='Country' order_date='Date' quantity='Quantity';

   sum price quantity;
   by sale_type;

   format price dollar7.2;

   title 'Retail and Quantity Totals for #byval(sale_type) Sales';
run;

options byline;

 Note about code
ods csvall close;

Output: CSV File

Summing Numeric Variables with One BY Group: CSV Output Viewed with a Microsoft Excel

[Summing Numeric Variables with One BY Group: CSV Output Viewed with a Microsoft Excel]

Previous Page | Next Page | Top of Page