The UNIVARIATE Procedure

Example 4.1 Computing Descriptive Statistics for Multiple Variables

This example computes univariate statistics for two variables. The following statements create the data set BPressure, which contains the systolic (Systolic) and diastolic (Diastolic) blood pressure readings for 22 patients:

data BPressure;
   length PatientID $2;
   input PatientID $ Systolic Diastolic @@;
   datalines;
CK 120 50  SS 96  60 FR 100 70
CP 120 75  BL 140 90 ES 120 70
CP 165 110 JI 110 40 MC 119 66
FC 125 76  RW 133 60 KD 108 54
DS 110 50  JW 130 80 BH 120 65
JW 134 80  SB 118 76 NS 122 78
GS 122 70  AB 122 78 EC 112 62
HH 122 82
;

The following statements produce descriptive statistics and quantiles for the variables Systolic and Diastolic:

title 'Systolic and Diastolic Blood Pressure';
ods select BasicMeasures Quantiles;
proc univariate data=BPressure;
   var Systolic Diastolic;
run;

The ODS SELECT statement restricts the output, which is shown in Output 4.1.1, to the BasicMeasures and Quantiles tables; see the section ODS Table Names. You use the PROC UNIVARIATE statement to request univariate statistics for the variables listed in the VAR statement, which specifies the analysis variables and their order in the output. Formulas for computing the statistics in the BasicMeasures table are provided in the section Descriptive Statistics. The quantiles are calculated using Definition 5, which is the default definition; see the section Calculating Percentiles.

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

Output 4.1.1: Display Basic Measures and Quantiles

Systolic and Diastolic Blood Pressure

The UNIVARIATE Procedure
Variable: Systolic

Basic Statistical Measures
Location Variability
Mean 121.2727 Std Deviation 14.28346
Median 120.0000 Variance 204.01732
Mode 120.0000 Range 69.00000
    Interquartile Range 13.00000

Note: The mode displayed is the smallest of 2 modes with a count of 4.


Quantiles (Definition 5)
Level Quantile
100% Max 165
99% 165
95% 140
90% 134
75% Q3 125
50% Median 120
25% Q1 112
10% 108
5% 100
1% 96
0% Min 96

Systolic and Diastolic Blood Pressure

The UNIVARIATE Procedure
Variable: Diastolic

Basic Statistical Measures
Location Variability
Mean 70.09091 Std Deviation 15.16547
Median 70.00000 Variance 229.99134
Mode 70.00000 Range 70.00000
    Interquartile Range 18.00000

Quantiles (Definition 5)
Level Quantile
100% Max 110
99% 110
95% 90
90% 82
75% Q3 78
50% Median 70
25% Q1 60
10% 50
5% 50
1% 40
0% Min 40