CHAPTER 22 Basic Descriptive Statistics 149
Directions
Produce the following
A. One-way frequency tables for the variables GENDER, PRIM_DX, SEC_DX, VITAMINS,
and PREGNANT.
B. Vertical bar charts for the variables GENDER and PRIM_DX.
PROBLEM 4
Generating Histograms for Numeric Variables
Tools
PROC CHART
Data
SAS data set CLINICAL
Directions
Produce the following charts
A. Construct a histogram for the variable HR (heart rate). Let PROC CHART select the midpoints
and the number of bars for the histogram.
B. Rerun part A, but specify that the midpoints for the bars should run from 40 to 100 and be
spaced 10 apart.
C. Rerun part A, but specify 10 bars.
PROBLEM 5
Computing Means where There Is More than One Observation per Subject
Tools
PROC MEANS
CLASS and OUTPUT statements
Data
Raw data file CLIN_X.DTA
150 The SAS Workbook
Directions
If you look at the contents of the CLIN_X.DTA data file you will see that there are from one
to five observations for each ID. If you want to compute the mean HR, SBP, and DBP for your
patients, you can first compute a mean for each ID and then take the mean of the means, or you
can select a single observation for each patient (such as the first or last).
Using the CLIN_X.DTA data file, create a SAS data set and compute an overall mean for HR,
SBP, and DBP using both of these methods. For the latter method, use the last visit for each
patient. Compute all statistics to three decimal places.
151
CHAPTER 23
PROBLEMS
1 Computing a Chi-square and Fisher's Exact Test from Raw Data . . . . . . . . . . . . . . .151
2 Computing a Chi-square from Frequency Counts . . . . . . . . . . . . . . . . . . . . . . . . . . . .152
3 Computing Two-way Frequencies: Chi-square and Fisher's Exact Test . . . . . . . . . . .152
4 Computing Several Chi-square Statistics from Frequency Counts . . . . . . . . . . . . . . .153
5 Computing a Chi-square on a 2 X 3 Table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
6 Testing Differences in Proportions for Paired Samples: McNemar's Test
(Raw Data) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
7 Testing Differences in Proportions for Paired Samples: McNemar's Test
(Frequency Data) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .155
INTRODUCTION
This chapter contains problems based on testing differences in proportions. Fisher’s Exact Test,
chi-square tests, and McNemar’s test are covered.
PROBLEM 1
Computing a Chi-square and Fisher’s Exact Test from Raw Data
Tools
PROC FREQ
Data
Raw data file CPR.DTA
Directions
Using the raw data in the CPR.DTA file, test if the proportion of patients surviving a cardiac
arrest is related to the three independent variables ventricular fibrillation (V_FIB), patient on a
respirator (RESP), and age greater than 70 (AGEGROUP). Compute both the chi-square statistic
and the Fisher’s exact test probability.
Tests of Proportions
152 The SAS Workbook
PROBLEM 2
Computing a Chi-square from Frequency Counts
Tools
PROC FREQ
WEIGHT statement
Data
Data were collected on GENDER (M and F) and voting preference (candidate A and candidate B).
The data appear as follows.
Gender Candidate Count
--------------------------------
M A 35
F A 45
M B 70
F B 50
Directions
Using the frequency count data in the Data section, compute chi-square.
PROBLEM 3
Computing Two-way Frequencies: Chi-square and Fisher’s Exact Test
Tools
PROC FREQ
Data
SAS data set CLINICAL
Directions
A. Using the SAS data set CLINICAL, create a two-way table of the variable VITAMINS by
the variable GENDER. The table should look like the following one.
GENDER
Female Male
-----------------
| | |
No | | |
VITAMINS -----------------
| | |
Yes | | |
-----------------

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.