144 The SAS Workbook
D. For all patients with a primary diagnosis (PRIM_DX) of 01, 02, or 04, compute frequencies
for the variables GENDER, VITAMINS, and PREGNANT. Do not create a separate data
set for this part.
E. Create a data set (PREG_35) containing all observations in CLINICAL for women who are
pregnant and over 35 years of age (as of May 1, 1996). List the ID, AGE (as of the last
birthday), and vitamin status of these women.
SECTION 4 Statistics Problems
CHAPTERS
22 Basic Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
23 Tests of Proportions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
24 Comparing Means: Two Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . .157
25 Analysis of Variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .161
26 Parametric and Nonparametric Correlations . . . . . . . . . . . . . . . . .173
27 Simple, Multiple, and Logistic Regression . . . . . . . . . . . . . . . . . . . . .177
28 Random Assignment and Random Selection of Subjects . . . . . . . .181
29 More Advanced Statistics Projects . . . . . . . . . . . . . . . . . . . . . . . . . .185
145
146
147
Chapter 22
PROBLEMS
1 Producing Basic Descriptive Statistics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
2 Computing Descriptive Statistics, Broken Down by More than One Variable . . . . . .148
3 Generating Frequency Distributions and Histograms for Categorical Variables . . . .148
4 Generating Histograms for Numeric Variables . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .149
5 Computing Means where There Is More than One Observation per Subject . . . . . .149
INTRODUCTION
The problems in this section cover topics ranging from simple descriptive statistics to more
advanced repeated measures analysis of variance. You can use them to sharpen your statistical
programming skills, and you can use the solutions as model programs for similar statistical
problems.
You may notice that the Tools lists do not go into as much detail (such as statements and options)
as those in previous chapters. The reason for this is that too much detail in the Tools list would
give too many hints on how to solve the problems and ruin your fun.
These problems test your ability to generate basic descriptive statistics such as means and
standard deviations; test distributions for normality; and produce frequency distributions,
histograms, and two-way tables.
PROBLEM 1
Producing Basic Descriptive Statistics
Tools
PROC MEANS
BY or CLASS statements
PROC UNIVARIATE
Data
SAS data set CLINICAL
Directions
Compute the following
Basic Descriptive Statistics
148 The SAS Workbook
A. The number of non-missing observations (n), the mean, standard deviation, and standard
error (all to three decimal places) for the variables HR (heart rate), SBP (systolic blood
pressure), and DBP (diastolic blood pressure) for all patients.
B. The same statistics listed in A, except compute them separately for males and females.
C. The median HR, SBP, and DBP.
D. A stem-and-leaf plot for SBP. Test if the distribution is significantly different from a normal
distribution (use α = .05).
PROBLEM 2
Computing Descriptive Statistics, Broken Down by More than One Variable
Tools
PROC MEANS
CLASS or BY statement
Data
SAS data set CLINICAL
Directions
Compute the N, mean, and standard deviation of HR, SBP, and DBP, for each level of GENDER
and age group, where two age groups are defined as
1 = less than 65
2 = greater than or equal to 65
Compute age as the age at the time of the visit, dropping any fractional part of a year. Express
all statistics to three decimal places.
PROBLEM 3
Generating Frequency Distributions and Histograms for Categorical Variables
Tools
PROC FREQ
PROC CHART
Data
SAS data set CLINICAL

Get The SAS Workbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.