Chapter Contents

Previous

Next
The MEANS Procedure

Example 12: Identifying the Top Three Extreme Values with the Output Statistics


Procedure features:
PROC MEANS statement option:
NOPRINT
CLASS statement
OUTPUT statement options:
statistic keywords
AUTOLABEL
AUTONAME
IDGROUP
TYPES statement
Other features:
FORMAT procedure
FORMAT statement
PRINT procedure
RENAME = data set option
Data set: CHARITY

This example


Program

options nodate pageno=1 linesize=80 pagesize=60;
 Note about code
 proc format;
   value yrFmt . = " All";
   value $schFmt ' ' = "All    ";
run;
 Note about code
proc means data=Charity noprint;
 Note about code
   class School Year;
 Note about code
   types () school year;
 Note about code
   var moneyraised;
 Note about code
   output out=top3list(rename=(_freq_=NumberStudents))sum= mean= 
          idgroup( max(moneyraised) out[3] (moneyraised name 
            school year)=)/autolabel autoname;
 Note about code
   label MoneyRaised='Amount Raised';
   format year yrfmt. school $schfmt.
          moneyraised dollar8.2;
  run;
 Note about code
proc print data=top3list;
   title1 'School Funding Raising Report';
   title2 'Top Three Students';
run;
 Note about code
proc datasets library=work nolist;
   contents data=top3list;
   title1 'Contents of the PROC MEANS Output Data Set';
  run;


Output
The output from PROC PRINT shows the top three values of MoneyRaised, the names of the students who raised these amounts, the schools the students attended, and the years when the money was raised. The first observation contains the overall results, the next three contain the results by year, and the final two contain the results by school. The missing class levels for School and Year are replaced with the value of ALL. [HTML Output]
 [Listing Output]
 Note about figure
                         School Funding Raising Report                         1
                               Top Three Students

                                     Money    Money
                          Number   Raised_  Raised_  Money    Money    Money
 Obs School  Year _TYPE_ Students      Sum     Mean Raised_1 Raised_2 Raised_3

  1  All      All    0      109   $3192.75   $29.29   $78.65   $72.22   $65.44
  2  All     1992    1       31    $892.92   $28.80   $55.16   $53.76   $52.63
  3  All     1993    1       32    $907.92   $28.37   $65.44   $47.33   $42.23
  4  All     1994    1       46   $1391.91   $30.26   $78.65   $72.22   $56.87
  5  Kennedy  All    2       53   $1575.95   $29.73   $72.22   $52.63   $43.89
  6  Monroe   All    2       56   $1616.80   $28.87   $78.65   $65.44   $56.87

 
 
 Obs Name_1  Name_2  Name_3  School_1 School_2 School_3 Year_1 Year_2 Year_3

  1  Willard Luther  Cameron Monroe   Kennedy  Monroe    1994   1994   1993 
  2  Tonya   Edward  Thelma  Monroe   Monroe   Kennedy   1992   1992   1992 
  3  Cameron Myrtle  Bill    Monroe   Monroe   Kennedy   1993   1993   1993 
  4  Willard Luther  L.T.    Monroe   Kennedy  Monroe    1994   1994   1994 
  5  Luther  Thelma  Jenny   Kennedy  Kennedy  Kennedy   1994   1992   1992 
  6  Willard Cameron L.T.    Monroe   Monroe   Monroe    1994   1993   1994 
                   Contents of the PROC MEANS Output Data Set                  2

                             The DATASETS Procedure

  Data Set Name: WORK.TOP3LIST                       Observations:         6  
  Member Type:   DATA                                Variables:            18 
  Engine:        V8                                  Indexes:              0  
  Created:       14:41 Tuesday, May 4, 1999          Observation Length:   144
  Last Modified: 14:41 Tuesday, May 4, 1999          Deleted Observations: 0  
  Protection:                                        Compressed:           NO 
  Data Set Type:                                     Sorted:               NO 
  Label:                                                                      


                  -----Engine/Host Dependent Information-----

Data Set Page Size:         16384                                               
Number of Data Set Pages:   1                                                   
First Data Page:            1                                                   
Max Obs per Page:           113                                                 
Obs in First Data Page:     6                                                   
Number of Data Set Repairs: 0                                                   
File Name:                  UNIX-pathname  
Release Created:            8.00.00B                                            
Host Created:               HP-UX                                               
Inode Number:               313604                                              
Access Permission:          rw-r--r--                                           
Owner Name:                 UNIX-userid                                              
File Size (bytes):          24576                                               


             -----Alphabetic List of Variables and Attributes-----
 
 #    Variable            Type    Len    Pos    Format       Label
-------------------------------------------------------------------------------
 7    MoneyRaised_1       Num       8     40    DOLLAR8.2    Amount Raised     
 8    MoneyRaised_2       Num       8     48    DOLLAR8.2    Amount Raised     
 9    MoneyRaised_3       Num       8     56    DOLLAR8.2    Amount Raised     
 6    MoneyRaised_Mean    Num       8     32    DOLLAR8.2    Amount Raised_Mean
 5    MoneyRaised_Sum     Num       8     24    DOLLAR8.2    Amount Raised_Sum 
10    Name_1              Char      7     95                                   
11    Name_2              Char      7    102                                   
12    Name_3              Char      7    109                                   
 4    NumberStudents      Num       8     16                                   
 1    School              Char      7     88    $SCHFMT.                       
13    School_1            Char      7    116    $SCHFMT.                       
14    School_2            Char      7    123    $SCHFMT.                       
15    School_3            Char      7    130    $SCHFMT.                       
 2    Year                Num       8      0    YRFMT.                         
16    Year_1              Num       8     64    YRFMT.                         
17    Year_2              Num       8     72    YRFMT.                         
18    Year_3              Num       8     80    YRFMT.                         
 3    _TYPE_              Num       8      8                                   

See the TEMPLATE procedure in The Complete Guide to the SAS Output Delivery System for an example of how to create a custom table definition for this output data set.


Chapter Contents

Previous

Next

Top of Page

Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.