An instructor is interested in calculating all the modes of the scores on a recent exam. The following statements create a data set named Exam, which contains the exam scores in the variable Score:
data Exam; label Score = 'Exam Score'; input Score @@; datalines; 81 97 78 99 77 81 84 86 86 97 85 86 94 76 75 42 91 90 88 86 97 97 89 69 72 82 83 81 80 81 ;
The following statements use the MODES option to request a table of all possible modes:
title 'Table of Modes for Exam Scores'; ods select Modes; proc univariate data=Exam modes; var Score; run;
The ODS SELECT statement restricts the output to the "Modes" table; see the section ODS Table Names.
Table of Modes for Exam Scores |
Modes | |
---|---|
Mode | Count |
81 | 4 |
86 | 4 |
97 | 4 |
By default, when the MODES option is used and there is more than one mode, the lowest mode is displayed in the "BasicMeasures" table. The following statements illustrate the default behavior:
title 'Default Output'; ods select BasicMeasures; proc univariate data=Exam; var Score; run;
Default Output |
Basic Statistical Measures | |||
---|---|---|---|
Location | Variability | ||
Mean | 83.66667 | Std Deviation | 11.08069 |
Median | 84.50000 | Variance | 122.78161 |
Mode | 81.00000 | Range | 57.00000 |
Interquartile Range | 10.00000 |
The default output displays a mode of 81 and includes a note regarding the number of modes; the modes 86 and 97 are not displayed. The ODS SELECT statement restricts the output to the "BasicMeasures" table; see the section ODS Table Names.
A sample program for this example, uniex02.sas, is available in the SAS Sample Library for Base SAS software.