MEANS Procedure

Example 8: Computing Output Statistics

Features:

PROC MEANS statement option: NOPRINT

CLASS statement

OUTPUT statement options:
statistic keywords
IDGROUP
LEVELS
WAYS
Other features:

PRINT procedure

Data set: GRADE

Details

This example does the following:
  • suppresses the display of PROC MEANS output
  • stores the average final grade in a new variable
  • stores the name of the student with the best final exam scores in a new variable
  • stores the number of class variables are that are combined in the _WAY_ variable
  • stores the value of the class level in the _LEVEL_ variable
  • displays the output data set

Program

options nodate pageno=1 linesize=80 pagesize=60;
proc means data=Grade noprint;
   class Status Year;
   var FinalGrade;
   output out=sumstat mean=AverageGrade
          idgroup (max(score) obs out (name)=BestScore)
          / ways levels;
run;
proc print data=sumstat noobs;
   title1 'Average Undergraduate and Graduate Course Grades';
   title2 'For Two Years';
run;

Program Description

Set the SAS system options. The NODATE option suppresses the display of the date and time in the output. PAGENO= specifies the starting page number. LINESIZE= specifies the output line length, and PAGESIZE= specifies the number of lines on an output page.
options nodate pageno=1 linesize=80 pagesize=60;
Specify the analysis options. NOPRINT suppresses the display of all PROC MEANS output.
proc means data=Grade noprint;
Specify subgroups for the analysis. The CLASS statement separates the analysis by values of Status and Year.
   class Status Year;
Specify the analysis variable. The VAR statement specifies that PROC MEANS calculate statistics on the FinalGrade variable.
   var FinalGrade;
Specify the output data set options. The OUTPUT statement creates the SUMSTAT data set and writes the mean value for the final grade to the new variable AverageGrade. IDGROUP writes the name of the student with the top exam score to the variable BestScore and the observation number that contained the top score. WAYS and LEVELS write information about how the class variables are combined.
   output out=sumstat mean=AverageGrade
          idgroup (max(score) obs out (name)=BestScore)
          / ways levels;
run;
Print the output data set WORK.SUMSTAT. The NOOBS option suppresses the observation numbers.
proc print data=sumstat noobs;
   title1 'Average Undergraduate and Graduate Course Grades';
   title2 'For Two Years';
run;

Output

The first observation contains the average course grade and the name of the student with the highest exam score over the two-year period. The next four observations contain values for each class variable value. The remaining four observations contain values for the Year and Status combination. The variables _WAY_, _TYPE_, and _LEVEL_ show how PROC MEANS created the class variable combinations. The variable _OBS_ contains the observation number in the GRADE data set that contained the highest exam score.
Average Course Grades
Average Undergraduate and Graduate Course Grades For Two Years