Previous Page | Next Page

Producing Detail Reports with the PRINT Procedure

Creating Customized Reports


Ways to Customize a Report

As you have seen from the previous examples, the PRINT procedure produces simple detail reports quickly and easily. With additional statements and options, you can enhance the readability of your reports. For example, you can do the following:


Understanding Titles and Footnotes

Adding descriptive titles and footnotes is one of the easiest and most effective ways to improve the appearance of a report. You can use the TITLE statement to include from 1 to 10 lines of text at the top of the report. You can use the FOOTNOTE statement to include from 1 to 10 lines of text at the bottom of the report.

In the TITLE statement, you can specify n immediately following the keyword TITLE, to indicate the level of the TITLE statement. n is a number from 1 to 10 that specifies the line number of the TITLE. You must enclose the text of each title in single or double quotation marks.

Skipping over some values of n indicates that those lines are blank. For example, if you specify TITLE1 and TITLE3 statements but skip TITLE2, then a blank line occurs between the first and third lines.

When you specify a title, SAS uses that title for all subsequent output until you cancel it or define another title for that line. A TITLE statement for a given line cancels the previous TITLE statement for that line and for all lines below it, that is, for those with larger n values.

To cancel all existing titles, specify a TITLE statement without the n value:

title;

To suppress the nthe title and all titles below it, use the following statement:

titlen;

Footnotes work the same way as titles. In the FOOTNOTE statement, you can specify n immediately following the keyword FOOTNOTE, to indicate the level of the FOOTNOTE statement. n is a number from 1 to 10 that specifies the line number of the FOOTNOTE. You must enclose the text of each footnote in single or double quotation marks. As with the TITLE statement, skipping over some values of n indicates that those lines are blank.

Remember that the footnotes are pushed up from the bottom of the report. In other words, the FOOTNOTE statement with the largest number appears on the bottom line.

When you specify a footnote, SAS uses that footnote for all subsequent output until you cancel it or define another footnote for that line. You cancel and suppress footnotes in the same way that you cancel and suppress titles.

Note:   The maximum title length and footnote length that is allowed depends on your operating environment and the value of the LINESIZE= system option. Refer to the SAS documentation for your operating environment for more information.   [cautionend]


Adding Titles and Footnotes

The following program includes titles and footnotes in a report of second quarter sales during the month of April:

options linesize=80 pageno=1 nodate;

proc sort data=qtr02;
   by SalesRep; 
run;

proc print data=qtr02 noobs;
   var SalesRep Month Units AmountSold;
   where Month='04';
   format Units comma7. AmountSold dollar14.2;
   sum Units AmountSold;
   title1 'TruBlend Coffee Makers, Inc.';
   title3 'Quarterly Sales Report';
   footnote1 'April Sales Totals';
   footnote2 'COMPANY CONFIDENTIAL INFORMATION';
run;

The report includes three title lines and two footnote lines. The program omits the TITLE2 statement so that the second title line is blank.

The following output shows the report:

Adding Titles and Footnotes

                          TruBlend Coffee Makers, Inc.1                          1
                                        2 
                             Quarterly Sales Report1 

              SalesRep         Month      Units        AmountSold

              Garcia            04          150         $4,645.50
              Garcia            04        1,715        $53,113.55
              Hollingsworth     04          260         $8,052.20
              Hollingsworth     04          530        $16,414.10
              Jensen            04        1,110        $34,376.70
              Jensen            04          675        $20,904.75
                                        =======    ==============
                                          4,440       $137,506.80
 
 
 
 
 
 
 
 
                               April Sales Totals3  
                        COMPANY CONFIDENTIAL INFORMATION3  
The following list corresponds to the numbered items in the preceding report:

[1] a descriptive title line that is generated by a TITLE statement

[2] a blank title line that is generated by omitting a TITLE statement for the second line

[3] a descriptive footnote line that is generated by a FOOTNOTE statement.


Defining Labels

By default, SAS uses variable names for column headings. However, to improve the appearance of a report, you can specify your own column headings.

To override the default headings, you need to do the following:

The LABEL option causes the report to display labels, instead of variable names, for the column headings. You use the LABEL statement to assign the labels for the specific variables. A label can be up to 256 characters long, including blanks, and must be enclosed in single or double quotation marks. If you assign labels when you created the SAS data set, then you can omit the LABEL statement from the PROC PRINT step.

The following program modifies the previous program and defines labels for the variables SalesRep, Units, and AmountSold:

options linesize=80 pageno=1 nodate;

proc sort data=qtr02;
   by SalesRep; 
run;

proc print data=qtr02 noobs label;
   var SalesRep Month Units AmountSold;
   where Month='04';
   format Units comma7. AmountSold dollar14.2;
   sum Units AmountSold;
   label SalesRep   = 'Sales Rep.'
         Units      = 'Units Sold'
         AmountSold = 'Amount Sold';
   title 'TruBlend Coffee Maker Sales Report for April';
   footnote;
run;

The TITLE statement redefines the first title and cancels any additional titles that might have been previously defined. The FOOTNOTE statement cancels any footnotes that might have been previously defined.

The following output shows the report:

Defining Labels

              TruBlend Coffee Maker Sales Report for April             1

                                      Units
          Sales Rep.       Month       Sold       Amount Sold

          Garcia            04          150         $4,645.50
          Garcia            04        1,715        $53,113.55
          Hollingsworth     04          260         $8,052.20
          Hollingsworth     04          530        $16,414.10
          Jensen            04        1,110        $34,376.70
          Jensen            04          675        $20,904.75
                                    =======    ==============
                                      4,440       $137,506.80
The label Units Sold is split between two lines. The PRINT procedure splits the label to conserve space.

Splitting Labels across Two or More Lines

Sometimes labels are too long to fit on one line, or you might want to split a label across two or more lines. By default, SAS automatically splits labels on the basis of column width. You can use the SPLIT= option to control where the labels are separated into multiple lines.

The SPLIT= option replaces the LABEL option in the PROC PRINT statement. (You do not need to use both SPLIT= and LABEL because SPLIT= implies that PROC PRINT use labels.) In the SPLIT= option, you specify an alphanumeric character that indicates where to split labels. To use the SPLIT= option, you need to do the following:

The following PROC PRINT step defines the slash (/) as the split character and includes slashes in the LABEL statements to split the labels Sales Representative, Units Sold, and Amount Sold into two lines each:

options linesize=80 pageno=1 nodate;

proc sort data=qtr02;
   by SalesRep; 
run;

proc print data=qtr02 noobs split='/';
   var SalesRep Month Units AmountSold;
   where Month='04';
   format Units comma7. AmountSold dollar14.2;
   sum Units AmountSold;
   title 'TruBlend Coffee Maker Sales Report for April';
   label SalesRep   = 'Sales/Representative'
         Units      = 'Units/Sold'
         AmountSold = 'Amount/Sold';
   run;

The following output shows the report:

Reporting: Splitting Labels into Two Lines

                  TruBlend Coffee Maker Sales Report for April                 1

                  Sales                    Units            Amount
              Representative    Month       Sold              Sold

              Garcia             04          150         $4,645.50
              Garcia             04        1,715        $53,113.55
              Hollingsworth      04          260         $8,052.20
              Hollingsworth      04          530        $16,414.10
              Jensen             04        1,110        $34,376.70
              Jensen             04          675        $20,904.75
                                         =======    ==============
                                           4,440       $137,506.80

Adding Double Spacing

You might want to improve the appearance of a report by adding double spaces between the rows of the report. The following program uses the DOUBLE option in the PROC PRINT statement to double-space the report:

options linesize=80 pageno=1 nodate;

proc sort data=qtr02;
   by SalesRep; 
run;

proc print data=qtr02 noobs split='/' double;
   var SalesRep Month Units AmountSold;
   where Month='04';
   format Units comma7. AmountSold dollar14.2;
   sum Units AmountSold;
   title 'TruBlend Coffee Maker Sales Report for April';
   label SalesRep   = 'Sales/Representative'
         Units      = 'Units/Sold'
         AmountSold = 'Amount/Sold';
   run;

The following output shows the report:

Adding Double Spacing

                  TruBlend Coffee Maker Sales Report for April                 1

                  Sales                    Units            Amount
              Representative    Month       Sold              Sold

              Garcia             04          150         $4,645.50

              Garcia             04        1,715        $53,113.55

              Hollingsworth      04          260         $8,052.20

              Hollingsworth      04          530        $16,414.10

              Jensen             04        1,110        $34,376.70

              Jensen             04          675        $20,904.75

                                         =======    ==============

                                           4,440       $137,506.80

Requesting Uniform Column Widths

By default, PROC PRINT uses the width of the formatted variable as the column width. If you do not assign a format to the variable that explicitly specifies a field width, then the column width is the widest value of the variable on that page. This can cause the column widths to vary on different pages of a report.

The WIDTH=UNIFORM option ensures that the columns of data line up from one page to the next. PROC PRINT will use a variable's formatted width or, if no format is assigned, the widest data value as the variable's column width on all pages. Unless you specify this option, PROC PRINT individually constructs each page of output. Each page contains as many variables and observations as possible. As a result, the report might have different numbers of variables or different column widths from one page to the next.

If the sales records for TruBlend Coffee Makers(footnote 1) are sorted by the sales representatives and a report is created without using the WIDTH=UNIFORM option in the PROC PRINT statement, then the columns of values on the first page will not line up with those on the next page. The column shift occurs because of differences in the name length of the sales representatives. PROC PRINT lines up the columns on the first page of the report, allowing enough space for the longest name, Hollingsworth . On the second page the longest name is Jensen , so the columns shift relative to the first page.

The following example uses the WIDTH= option in the PROC PRINT statement to prevent the shifting of columns:

options pagesize=66 linesize=80 pageno=1 nodate;

proc sort data=qtr03;
   by SalesRep;
run;

proc print data=qtr03 split='/' width=uniform;
   var SalesRep Month Units AmountSold;
   format Units comma7. AmountSold dollar14.2;
   sum Units AmountSold;
   title 'TruBlend Coffee Makers 3rd Quarter Sales Report';
   label SalesRep    = 'Sales/Rep.'
         Units       = 'Units/Sold'
         AmountSold  = 'Amount/Sold';
run;

The following output shows the report:

Reporting: Using Uniform Column Widths

                TruBlend Coffee Makers 3rd Quarter Sales Report                1

                  Sales                       Units            Amount
           Obs    Rep.             Month       Sold              Sold

             1    Garcia            07          250         $7,742.50
             2    Garcia            07           90         $2,787.30
             3    Garcia            07           90         $2,787.30
             4    Garcia            07          265         $8,207.05
             5    Garcia            07        1,250        $38,712.50
             6    Garcia            07           90         $2,787.30
             7    Garcia            07           90         $2,787.30
             8    Garcia            07          465        $14,401.05
             9    Garcia            08          110         $5,445.00
            10    Garcia            08          240         $7,432.80
            11    Garcia            08          198         $6,132.06
            12    Garcia            08        1,198        $37,102.06
            13    Garcia            08          110         $5,445.00
            14    Garcia            08          240         $7,432.80
            15    Garcia            08          198         $6,132.06
            16    Garcia            09          118         $3,654.46
            17    Garcia            09          412        $12,759.64
            18    Garcia            09          100         $3,097.00
            19    Garcia            09        1,118        $34,624.46
            20    Garcia            09          412        $12,759.64
            21    Garcia            09          100         $3,097.00
            22    Hollingsworth     07           60         $2,970.00
            23    Hollingsworth     07           30         $1,485.00
            24    Hollingsworth     07          130         $4,026.10
            25    Hollingsworth     07           60         $2,970.00
            26    Hollingsworth     07          330        $10,220.10
            27    Hollingsworth     08          120         $3,716.40
            28    Hollingsworth     08          230         $7,123.10
            29    Hollingsworth     08          230        $11,385.00
            30    Hollingsworth     08          290         $8,981.30
            31    Hollingsworth     08          330        $10,220.10
            32    Hollingsworth     08           50         $2,475.00
            33    Hollingsworth     09          125         $3,871.25
            34    Hollingsworth     09        1,000        $30,970.00
            35    Hollingsworth     09          125         $3,871.25
            36    Hollingsworth     09          175         $5,419.75
            37    Jensen            07          110         $3,406.70
            38    Jensen            07          110         $3,406.70
            39    Jensen            07          275         $8,516.75
            40    Jensen            07          110         $3,406.70
            41    Jensen            07          110         $3,406.70
            42    Jensen            07          675        $20,904.75
            43    Jensen            08          145         $4,490.65
            44    Jensen            08          453        $14,029.41
            45    Jensen            08          453        $14,029.41
            46    Jensen            08           45         $2,227.50
            47    Jensen            08          145         $4,490.65
            48    Jensen            08          453        $14,029.41
            49    Jensen            08          225        $11,137.50
            50    Jensen            09          254         $7,866.38
            51    Jensen            09          284         $8,795.48
            52    Jensen            09          275        $13,612.50
            53    Jensen            09          876        $27,129.72
            54    Jensen            09          254         $7,866.38
            55    Jensen            09          284         $8,795.48
                TruBlend Coffee Makers 3rd Quarter Sales Report                2

                  Sales                       Units            Amount
           Obs    Rep.             Month       Sold              Sold

            56    Jensen            09          275        $13,612.50
            57    Jensen            09          876        $27,129.72
                                            =======    ==============
                                             17,116       $557,321.62

FOOTNOTE 1:   See Input File and SAS Data Sets for Examples to examine the sales records. [arrow]

Previous Page | Next Page | Top of Page