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
The UNIVARIATE Procedure
Variable: Systolic
121.2727 |
14.28346 |
120.0000 |
204.01732 |
120.0000 |
69.00000 |
|
13.00000 |
Note: The mode displayed is the smallest of 2 modes with a count of 4. |
165 |
165 |
140 |
134 |
125 |
120 |
112 |
108 |
100 |
96 |
96 |
The UNIVARIATE Procedure
Variable: Diastolic
70.09091 |
15.16547 |
70.00000 |
229.99134 |
70.00000 |
70.00000 |
|
18.00000 |
110 |
110 |
90 |
82 |
78 |
70 |
60 |
50 |
50 |
40 |
40 |