8.4 Screening Extreme & Missing Values with PROC UNIVARIATE

Key Takeaways

  • The A00-231 content guide names PROC UNIVARIATE specifically for identifying extreme and missing values in a data set.
  • Default output comprises five tables: Moments, Basic Statistical Measures, Tests for Location, Quantiles, and Extreme Observations.
  • The Extreme Observations table lists the five lowest and five highest values with their observation numbers, and NEXTROBS=n changes that count.
  • The Moments table reports N alongside N Miss, giving the missing-value count for each analysis variable without a separate step.
  • The ID statement replaces observation numbers in the Extreme Observations table with a meaningful key such as a customer or patient identifier.
Last updated: August 2026

8.4 Screening Extreme & Missing Values with PROC UNIVARIATE

Quick Answer: The content guide's summary-reporting objective ends with a bullet that names one procedure by name: "Identify extreme and missing values with the UNIVARIATE procedure." PROC UNIVARIATE produces a far richer distributional profile than PROC MEANS, and its Extreme Observations table — the five lowest and five highest values with their observation numbers — is the feature the exam is pointing at.


1. The Simplest Invocation

proc univariate data=sashelp.class;
   var Height Weight;
run;

For each analysis variable, SAS prints five tables:

TableWhat it reports
MomentsN, N Miss, Mean, Sum, Std Deviation, Variance, Skewness, Kurtosis, and sums of squares
Basic Statistical MeasuresMean, Median, Mode; Std Deviation, Variance, Range, Interquartile Range
Tests for LocationStudent's t, Sign, and Signed Rank tests of whether the mean or median differs from zero
Quantiles100% Max, 99%, 95%, 90%, 75% Q3, 50% Median, 25% Q1, 10%, 5%, 1%, 0% Min
Extreme ObservationsThe five lowest and five highest values with their observation numbers

That last table is the reason the procedure exists for this objective. PROC MEANS tells you the minimum is -999; PROC UNIVARIATE tells you the minimum is -999, that it occurs at observation 412, and that the next four smallest values are 50, 51, 52, and 53 — which immediately identifies -999 as a sentinel code rather than a real measurement.


2. Reading the Extreme Observations Table

                          Extreme Observations

        -----Lowest-----            -----Highest----

        Value      Obs              Value      Obs

          -999     412                  78       19
            50      88                  79        3
            51     205                  80       11
            52      17                  81       15
            53      94                 999      377

Two sentinel values (-999 and 999) stand out instantly against a body of plausible heights, and the Obs column tells you exactly which rows to inspect.

Controlling How Many Extremes Appear

/* Show the 10 lowest and 10 highest instead of the default 5 */
proc univariate data=work.patients nextrobs=10;
   var SystolicBP;
run;

NEXTROBS=n sets the number of extreme observations listed. A closely related option, NEXTRVAL=n, prints the n extreme values without observation numbers.

Making the Listing Meaningful with ID

Observation numbers are useless once a data set has been sorted or subset. The ID statement replaces them with a real key.

proc univariate data=work.patients nextrobs=10;
   var SystolicBP;
   id PatientID;
run;

The Extreme Observations table now shows PatientID beside each value, so the outlier can be traced back to a record rather than a row position.


3. Counting Missing Values

The Moments table reports N and N Miss side by side:

                                Moments

N                          185    Sum Weights              185
Mean                  62.336757   Sum Observations       11532.3
Std Deviation         5.1270985   Variance              26.287139
N Miss                      15

N is the count of non-missing values used in every statistic; N Miss is the count of missing values excluded from them. For a variable meant to be fully populated, a non-zero N Miss is an immediate data-quality finding — and you get it without writing a separate PROC MEANS ... NMISS or PROC FREQ ... MISSING step.

Exam Trap: every statistic in PROC UNIVARIATE — like every statistic in PROC MEANS — is computed on non-missing values only. A mean of 62.3 over N = 185 says nothing about the 15 missing rows. N Miss is what quantifies the gap.


4. Subgroup Screening with CLASS and BY

/* One profile per treatment group, no pre-sorting required */
proc univariate data=work.trial;
   class Treatment;
   var Response;
   id SubjectID;
run;

/* BY requires the data to be sorted first */
proc sort data=work.trial out=work.trial_sorted;
   by Site;
run;

proc univariate data=work.trial_sorted;
   by Site;
   var Response;
run;

As in PROC MEANS, CLASS handles unsorted data while BY requires a prior PROC SORT. Screening by subgroup often reveals that an "outlier" is perfectly normal within its own stratum.


5. Trimming the Output

The full five-table report is heavy when you only want the extremes. Two mechanisms cut it down:

/* Statement-level: keep only the extremes and the moments */
ods select ExtremeObs Moments;

proc univariate data=work.patients nextrobs=10;
   var SystolicBP;
   id PatientID;
run;

ods select all;   /* restore default behaviour */
/* Capture the extremes into a data set for programmatic follow-up */
ods output ExtremeObs = work.outliers;

proc univariate data=work.patients nextrobs=10;
   var SystolicBP;
run;

The NOPRINT option suppresses all printed output, which is appropriate when the goal is purely to build an output data set.


6. UNIVARIATE versus MEANS

QuestionProcedure
What is the mean, sum, or standard deviation by group?PROC MEANS
Which specific rows hold the highest and lowest values?PROC UNIVARIATE
How many values are missing?Either (NMISS in MEANS, N Miss in MEANS and UNIVARIATE)
Is the distribution skewed, and where do the quartiles fall?PROC UNIVARIATE
I need a compact summary table for a reportPROC MEANS
I need to screen a new data set for bad values before trusting itPROC UNIVARIATE

The one-line rule: PROC MEANS summarizes the data you believe in; PROC UNIVARIATE tells you whether you should.

Test Your Knowledge

Which PROC UNIVARIATE output table is the exam content guide pointing at when it names the procedure for identifying extreme values?

A
B
C
D
Test Your Knowledge

A data-quality review must list the 10 lowest and 10 highest blood-pressure readings alongside each patient's identifier. Which PROC UNIVARIATE step does this?

A
B
C
D
Test Your Knowledge

Where does PROC UNIVARIATE report the number of missing values for an analysis variable?

A
B
C
D
Test Your Knowledge

An analyst wants to keep only the Extreme Observations table from a PROC UNIVARIATE step and suppress the other four default tables. Which approach works?

A
B
C
D