Example 2.6. Suppressing the Display of Specific Columns

Goal

List observations in a data set and summarize selected numeric variables. Summarize over all observations and summarize within groups. Summarize specific variables within an observation and add these summaries as columns in the report. Display the summary columns. Do not display the variables used to calculate the summaries.

Report

                     Regional Energy
  Quarterly Use by Residential and Commercial
 Customers

                                 First    Second
                               Quarter   Quarter
             Service             Total     Total  
    Total
Commercial   Area Lights        36,058    36,296  
   72,354
             Flood Lights       39,061    36,082  
   75,143
             General Service     2,572     2,977  
    5,549
             Off Peak           40,206    35,634  
   75,840
             Other Service       4,700     4,851  
    9,551
             Space Heating         317       337  
      654
             Water Heating         458       389  
      847
===========                    ========  ======== 
 ========
Commercial                     123,372   116,566  
  239,938
===========                    ========  ======== 
 ========

Residential  Area Lights           325       324  
      649
             Flood Lights          260       244  
      504
             General Service    66,342    74,132  
  140,474
             Off Peak            3,212     3,073  
    6,285
             Other Service         633       656  
    1,289
             Space Heating      29,375    38,029  
   67,404
             Water Heating      34,374    34,376  
   68,750
===========                    ========  ======== 
 ========
Residential                    134,521   150,834  
  285,355
===========                    ========  ======== 
 ========

                               ========  ======== 
 ========
                               257,893   267,400  
  525,293
                               ========  ======== 
 ========


Example Features

Data SetPOWERUSE
Featured StepPROC REPORT
Featured Step Statements and OptionsDEFINE statement: ANALYSIS, COMPUTED, NOPRINT, ORDER, and SUM options

COMPUTE blocks to create new variables

BREAK AFTER statement: SUMMARIZE option

RBREAK AFTER statement: SUMMARIZE option
Formatting FeaturesControlling line breaks in column headings

DEFINE statement: WIDTH option when sending output to the LISTING destination.

BREAK and RBREAK statements: DOL, DUL, and SKIP options when sending output to the LISTING destination
Other Examples That Use This Data SetExamples 2.4, 2.5, and 6.10

Example Overview

This report includes only the summary columns from Example 2.5. It presents energy usage by type of service for commercial and residential customers by quarter. This example sums columns and rows. It suppresses the display of the analysis variables used to compute the quarter totals, which were displayed in Example 2.5.

Each detail row in the report—those with a value for SERVICE—corresponds to one observation in the POWERUSE data set. The other rows, which are summaries of the detail rows, were created by the PROC REPORT statements, BREAK and RBREAK.

The columns for customer group and type of service each correspond to a variable in the POWERUSE data set. PROC REPORT defines the other three columns. It calculates their values with programming statements in COMPUTE blocks. The calculations sum the monthly usage variables in the POWERUSE data set.

Program

Create formats for TYPE and SERVICE.
proc format;
  value $type    'res'='Residential'
                 'com'='Commercial';
  value $service 'gen'='General Service'
                 'wtr'='Water Heating'
                 'op' ='Off Peak'
                 'spc'='Space Heating'
                 'fld'='Flood Lights'
                 'area'='Area Lights'
                 'oth'='Other Service';
run;
options ls=120 ps=45;

title 'Regional Energy';
title2 'Quarterly Use by Residential and Commercial
        Customers';

proc report data=poweruse nowindows

Specify the split character to control line breaks in column headings
     split='/';

List the columns in the order in which they should appear in the report. Include in the list the computed variables and the variables that will not be displayed. Ensure that the columns used to calculate the value of a computed variable precede the computed variable.
  column type service
         jan feb mar apr may jun
         quarter1 quarter2 total;

Order the detail rows according to the ascending, formatted values of the order variables. Establish the order of the detail rows by sorting the order variables from left to right according to their position in the COLUMN statement. Specify the column width when sending output to the LISTING destination.
  define type    / order format=$type. width=11 ' ';
  define service / order format=$service. width=15
                  'Service';

Enhance the report. For each column variable that will be displayed: assign a format; specify a column width (when sending output to the LISTING destination); and specify a column heading. Suppress the column heading for TYPE by enclosing a blank within single quotation marks. 
Do not display the next six variables in the report. Therefore, do not include options to format these columns. Calculate the SUM statistic for each of the six analysis variables.
  define jan      / analysis sum noprint;
  define feb      / analysis sum noprint;
  define mar      / analysis sum noprint;
  define apr      / analysis sum noprint;
  define may      / analysis sum noprint;
  define jun      / analysis sum noprint;

Define the computed columns. Split the column headings for QUARTER1 and QUARTER2 over three lines.
  define quarter1 / computed 'First/Quarter/Total'
                    width=8
                    format=comma8.;
  define quarter2 / computed 'Second/Quarter/Total'
                    width=8
                    format=comma8.;
  define total    / computed 'Total' width=8
                    format=comma8.;

Calculate the values of each computed variable. Define a COMPUTE block for each variable.
  compute quarter1;

Sum specific analysis variables. Represent the analysis variables with a compound name. Use the SUM function so that the computed variable is equal to the sum of the nonmissing arguments; this prevents generation of missing values when at least one of the arguments is nonmissing.
    quarter1=sum(jan.sum,feb.sum,mar.sum);
  endcomp;

  compute quarter2;
    quarter2=sum(apr.sum,may.sum,jun.sum);
  endcomp;

Compute the value of a new report variable by summing the values of two computed variables. Do not specify the arguments to the SUM function with compound names, since they are not analysis variables.
  compute total;
    total=sum(quarter1,quarter2);
  endcomp;

Summarize the analysis variables and computed variables over all observations with the same value of TYPE. Write the summaries on the line after the last row for each value of TYPE. When sending output to the LISTING destination, place a double overline and a double underline above and below the summary row, and skip a line after the double underline.
  break after type / summarize dol dul skip;

Sum the analysis variables and computed variables over all observations. Write the summary at the end of the report. When sending output to the LISTING destination, place a double overline and a double underline above and below the summary row, and skip a line after the double underline.
  rbreak after / summarize dol dul skip;
run;


Where to Go from Here

PROC REPORT reference and usage information. See “The REPORT Procedure” in the “Procedures” section of Base SAS 9.1 Procedures Guide.

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

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