In: Statistics and Probability
(A review on SAS data management)
The following is a data set of 12 individuals. And we want to
relate the heart rate at rest (Y) to kilograms body weight (X).
90 62
87 41
87 63
73 46
73 53
86 55
100 70
75 47
76 49
87 69
79 41
78 48
Write a program in SAS which read the given data set into SAS library.
In your program, create a new data set which is a copy of the
first, with the addition of a new variable which represents the
weight in pounds (1 kilogram 2.2 pounds). Use “proc print” to view
the data for all three variables.
(c) Create a new variable called weight_group which divides the
data set into four groups based on the estimated quartiles for the
variable weight. The estimated quartiles may be requested using the
keywords q1, median, and q3, in the “proc means”
statement.
(d) Use “proc freq” to summarize the frequency of subjects in
each of the four groups.
(e) Obtain the mean and standard deviation for the heart rate at rest for each of the four groups. Comment on the results.
(f) Produce a scatterplot of the heart rate at rest versus body
weight in kilograms. Describe what you see.
(g)Fit a straight line model for heart rate at rest versus body weight in kilograms. Comment on the fit of the line.
code :
data mydata;
input x y;
datalines;
90 62
87 41
87 63
73 46
73 53
86 55
100 70
75 47
76 49
87 69
79 41
78 48
;
run;
proc print data=mydata;
run;
data newdata;
set mydata;
weight_pound=x*2.2;
run;
proc print data=newdata;
run;
/*(c)*/
proc means data=newdata q1 q3 median;
run;
/*(d)*/
proc freq data=newdata;
run;
output:
The SAS System |
Obs | x | y | weight_pound |
---|---|---|---|
1 | 90 | 62 | 198.0 |
2 | 87 | 41 | 191.4 |
3 | 87 | 63 | 191.4 |
4 | 73 | 46 | 160.6 |
5 | 73 | 53 | 160.6 |
6 | 86 | 55 | 189.2 |
7 | 100 | 70 | 220.0 |
8 | 75 | 47 | 165.0 |
9 | 76 | 49 | 167.2 |
10 | 87 | 69 | 191.4 |
11 | 79 | 41 | 173.8 |
12 | 78 | 48 | 171.6 |
The SAS System |
The MEANS Procedure
Variable | Lower Quartile | Upper Quartile | Median | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
The SAS System |
The FREQ Procedure
x | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
73 | 2 | 16.67 | 2 | 16.67 |
75 | 1 | 8.33 | 3 | 25.00 |
76 | 1 | 8.33 | 4 | 33.33 |
78 | 1 | 8.33 | 5 | 41.67 |
79 | 1 | 8.33 | 6 | 50.00 |
86 | 1 | 8.33 | 7 | 58.33 |
87 | 3 | 25.00 | 10 | 83.33 |
90 | 1 | 8.33 | 11 | 91.67 |
100 | 1 | 8.33 | 12 | 100.00 |
y | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
41 | 2 | 16.67 | 2 | 16.67 |
46 | 1 | 8.33 | 3 | 25.00 |
47 | 1 | 8.33 | 4 | 33.33 |
48 | 1 | 8.33 | 5 | 41.67 |
49 | 1 | 8.33 | 6 | 50.00 |
53 | 1 | 8.33 | 7 | 58.33 |
55 | 1 | 8.33 | 8 | 66.67 |
62 | 1 | 8.33 | 9 | 75.00 |
63 | 1 | 8.33 | 10 | 83.33 |
69 | 1 | 8.33 | 11 | 91.67 |
70 | 1 | 8.33 | 12 | 100.00 |
weight_pound | Frequency | Percent | Cumulative Frequency |
Cumulative Percent |
---|---|---|---|---|
160.6 | 2 | 16.67 | 2 | 16.67 |
165 | 1 | 8.33 | 3 | 25.00 |
167.2 | 1 | 8.33 | 4 | 33.33 |
171.6 | 1 | 8.33 | 5 | 41.67 |
173.8 | 1 | 8.33 | 6 | 50.00 |
189.2 | 1 | 8.33 | 7 | 58.33 |
191.4 | 3 | 25.00 | 10 | 83.33 |
198 | 1 | 8.33 | 11 | 91.67 |
220 | 1 | 8.33 | 12 | 100.00 |