- Syntax
- Overview
- Concepts
- Using
- Results
- Examples Computing Specific Descriptive StatisticsComputing Descriptive Statistics with Class VariablesUsing the BY Statement with Class VariablesUsing a CLASSDATA= Data Set with Class VariablesUsing Multilabel Value Formats with Class VariablesUsing Preloaded Formats with Class VariablesComputing a Confidence Limit for the MeanComputing Output StatisticsComputing Different Output Statistics for Several VariablesComputing Output Statistics with Missing Class Variable ValuesIdentifying an Extreme Value with the Output StatisticsIdentifying the Top Three Extreme Values with the Output StatisticsUsing the STACKODSOUTPUT option to control data
- References

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 |

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;

Create the YRFMT. and $SCHFMT. formats. PROC FORMAT creates user-defined formats that assign
the value of All to the
missing levels of the class variables.

Generate the default statistics and specify the analysis
options. NOPRINT suppresses the display
of all PROC MEANS output.

Specify subgroups for the analysis. The CLASS statement separates the analysis by values
of School and Year.

Specify which subgroups to analyze. The TYPES statement requests the analysis across
all the observations and for each one-way combination of School and
Year.

Specify the analysis variable. The
VAR statement specifies that PROC MEANS calculate statistics on the
MoneyRaised variable.

Specify the output data set options. The OUTPUT statement creates the TOP3LIST data set.
RENAME= renames the _FREQ_ variable that contains frequency count
for each class level. SUM= and MEAN= specify that the sum and mean
of the analysis variable (MoneyRaised) are written to the output data
set. IDGROUP writes 12 variables that contain the top three amounts
of money raised and the three corresponding students, schools, and
years. AUTOLABEL appends the analysis variable name to the label for
the output variables that contain the sum and mean. AUTONAME resolves
naming conflicts for these variables.

output out=top3list(rename=(_freq_=NumberStudents))sum= mean= idgroup( max(moneyraised) out[3] (moneyraised name school year)=)/autolabel autoname;

Format the output. The LABEL
statement assigns a label to the analysis variable MoneyRaised. The
FORMAT statement assigns user-defined formats to the Year and School
variables and a SAS dollar format to the MoneyRaised variable.

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 ALL. The labels for
the variables that contain statistics that were computed from MoneyRaised
include the statistic name at the end of the label.