Procedure features: |
PROC
MEANS statement option:
|
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
-
suppresses the display of PROC MEANS output
-
analyzes the data for the one-way combination
of the class variables and across all observations
-
stores the total and average amount of money raised
in new variables
-
stores in new variables the top three amounts
of money raised, the names of the three students who raised the money, the
years when it occurred, and the schools the students attended
-
automatically resolves conflicts in the variable
names when names are assigned to the new variables in the output data set
-
appends the statistic name to the label of the variables in the
output data set that contain statistics that were computed for the analysis
variable.
-
assigns a format to the analysis variable so that
the statistics that are computed from this variable inherit the attribute
in the output data set
-
renames the _FREQ_ variable in the output data
set
-
displays the output data set and its contents.
|
options nodate pageno=1 linesize=80 pagesize=60; |
|
proc format;
value yrFmt . = " All";
value $schFmt ' ' = "All ";
run; |
|
proc means data=Charity noprint; |
|
class School Year; |
|
types () school year; |
|
var MoneyRaised; |
|
output out=top3list(rename=(_freq_=NumberStudents))sum= mean=
idgroup( max(moneyraised) out[3] (moneyraised name
school year)=)/autolabel autoname; |
|
label MoneyRaised='Amount Raised';
format year yrfmt. school $schfmt.
moneyraised dollar8.2;
run; |
|
proc print data=top3list;
title1 'School Fund Raising Report';
title2 'Top Three Students';
run; |
|
proc datasets library=work nolist;
contents data=top3list;
title1 'Contents of the PROC MEANS Output Data Set';
run; |
|
School Fund 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 V9 Indexes 0
Created 18:59 Thursday, March 14, 2008 Observation Length 144
Last Modified 18:59 Thursday, March 14, 2008 Deleted Observations 0
Protection Compressed NO
Data Set Type Sorted NO
Label
Data Representation WINDOWS
Encoding wlatin1 Western (Windows)
Engine/Host Dependent Information
Data Set Page Size 12288
Number of Data Set Pages 1
First Data Page 1
Max Obs per Page 85
Obs in First Data Page 6
Number of Data Set Repairs 0
File Name filename
Release Created 9.0000B0
Host Created WIN_PRO
Alphabetic List of Variables and Attributes
# Variable Type Len Format Label
7 MoneyRaised_1 Num 8 DOLLAR8.2 Amount Raised
8 MoneyRaised_2 Num 8 DOLLAR8.2 Amount Raised
9 MoneyRaised_3 Num 8 DOLLAR8.2 Amount Raised
6 MoneyRaised_Mean Num 8 DOLLAR8.2 Amount Raised_Mean
5 MoneyRaised_Sum Num 8 DOLLAR8.2 Amount Raised_Sum
10 Name_1 Char 7
11 Name_2 Char 7
12 Name_3 Char 7
4 NumberStudents Num 8
1 School Char 7 $SCHFMT.
13 School_1 Char 7 $SCHFMT.
14 School_2 Char 7 $SCHFMT.
15 School_3 Char 7 $SCHFMT.
2 Year Num 8 YRFMT.
16 Year_1 Num 8 YRFMT.
17 Year_2 Num 8 YRFMT.
18 Year_3 Num 8 YRFMT.
3 _TYPE_ Num 8
| |
See the TEMPLATE procedure in
SAS Output Delivery System: User's Guide for an example of how to create
a custom table definition for this output data set.
Copyright © 2010 by SAS Institute Inc., Cary, NC, USA. All rights reserved.