The UNIVARIATE Procedure

Example 4.3 Identifying Extreme Observations and Extreme Values

This example, which uses the data set BPressure introduced in Example 4.1, illustrates how to produce a table of the extreme observations and a table of the extreme values in a data set. The following statements generate the "Extreme Observations" tables for Systolic and Diastolic, which enable you to identify the extreme observations for each variable:

title 'Extreme Blood Pressure Observations';
ods select ExtremeObs;
proc univariate data=BPressure;
   var Systolic Diastolic;
   id PatientID;
run;

The ODS SELECT statement restricts the output to the "ExtremeObs" table; see the section ODS Table Names. The ID statement requests that the extreme observations are to be identified using the value of PatientID as well as the observation number. By default, the five lowest and five highest observations are displayed. You can use the NEXTROBS= option to request a different number of extreme observations.

Output 4.3.1 shows that the patient identified as 'CP' (Observation 7) has the highest values for both Systolic and Diastolic. To visualize extreme observations, you can create histograms; see Example 4.14.

Output 4.3.1: Blood Pressure Extreme Observations

Extreme Blood Pressure Observations

The UNIVARIATE Procedure
Variable: Systolic

Extreme Observations
LowestHighest
ValuePatientIDObsValuePatientIDObs
96SS2130JW14
100FR3133RW11
108KD12134JW16
110DS13140BL5
110JI8165CP7

Extreme Blood Pressure Observations

The UNIVARIATE Procedure
Variable: Diastolic

Extreme Observations
LowestHighest
ValuePatientIDObsValuePatientIDObs
40JI880JW14
50DS1380JW16
50CK182HH22
54KD1290BL5
60RW11110CP7


The following statements generate the "Extreme Values" tables for Systolic and Diastolic, which tabulate the tails of the distributions:

title 'Extreme Blood Pressure Values';
ods select ExtremeValues;
proc univariate data=BPressure nextrval=5;
   var Systolic Diastolic;
run;

The ODS SELECT statement restricts the output to the "ExtremeValues" table; see the section ODS Table Names. The NEXTRVAL= option specifies the number of extreme values at each end of the distribution to be shown in the tables in Output 4.3.2.

Output 4.3.2 shows that the values 78 and 80 occurred twice for Diastolic and the maximum of Diastolic is 110. Note that Output 4.3.1 displays the value of 80 twice for Diastolic because there are two observations with that value. In Output 4.3.2, the value 80 is only displayed once.

Output 4.3.2: Blood Pressure Extreme Values

Extreme Blood Pressure Values

The UNIVARIATE Procedure
Variable: Systolic

Extreme Values
LowestHighest
OrderValueFreqOrderValueFreq
1961111301
21001121331
31081131341
41102141401
51121151651

Extreme Blood Pressure Values

The UNIVARIATE Procedure
Variable: Diastolic

Extreme Values
LowestHighest
OrderValueFreqOrderValueFreq
140111782
250212802
354113821
460214901
5621151101


A sample program for this example, uniex01.sas, is available in the SAS Sample Library for Base SAS software.

Last updated: April 16, 2025