Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Central and Variability Proc

data my_data;
input team $ X Y;
datalines;
A 10 2
A 17 5
A 17 6
A 18 3
A 15 0
B 10 2
B 14 5
B 13 4
B 29 0
B 25 2
C 12 1
C 30 1
C 34 3
C 12 4
C 11 7
;
proc print data=my_data;
proc means data=my_data;
var X Y;
proc means data=my_data;
class team;
var X Y;
proc univariate data=my_data;
var X Y;
proc univariate data=my_data;
class team;
var X Y;
run;
Outlier Value
data my_data;
input team $ X Y;
datalines;
A 10 2
A 17 5
A 17 6
A 18 3
A 15 0
B 10 2
B 14 5
B 13 4
B 29 0
B 25 2
C 12 1
C 30 1
C 54 11
C 12 4
C 11 7
;
proc print data=my_data;
proc univariate data=my_data;
var X Y;
run;
Coefficient of Variation
DATA lambs;
INPUT weight @@;
DATALINES;
26 26 23 28 29 28 26 27 26 30
28 29 26 25 27 32 32 25 32 22
;
PROC MEANS DATA = lambs N MEAN MIN MAX VAR STD CV;
VAR weight;
RUN;
Simple T Test
Example: Evan vet company claimed that the total P. of her product was20%.
To test this claim 24 sample were taken randomly to made the analysis for them
at lab. and the results were as follow:
1 19.3, 2 19.4, 3 19.6 ………….24 19.5
Test the claim at L.S 0.05……
DATA D1;
INPUT No SCORE;
DATALINES;
01 19.3
02 19.4
03 19.6
04 18.3
05 18.8
06 18.6
07 18.8
08 18.5
09 18.4
10 18.4
11 19.1
12 19.1
13 19.4
14 19.3
15 18.8
16 18.9
17 18.9
18 18.6
19 18.5
20 18.4
21 19.1
22 18.5
23 18
24 19.5
;
PROC TTEST DATA=D1 H0=20 ALPHA=0.01;
VAR SCORE;
RUN;
SAS Examples for Hypotheses Tests of Two
Population Means
Example: Groups of goat were injected with gonadotropin or saline. The aim of
the experiment was to determine if the gonadotropin would result in higher
ovulation rate. The following ovulation rates were measured:
Gonadotropin 14 14 7 45 18 36 15
Saline 12 11 12 12 14 13 9

DATA superov;
INPUT trmt $ OR @@;
DATALINES;
G 14 G 14 G 7 G 45 G 18 G 36 G 15
S 12 S 11 S 12 S 12 S 14 S 13 S 9
;
PROC TTEST DATA=superov;
CLASS trmt;
VAR OR;
RUN;
TTEST Independent samples
DATA D1 ;
INPUT SUB_NUM
AFTNOON
MORNING;
DATALINES;
01 16 13
02 14 14
03 12 9
04 16 12
05 13 12
06 11 13
07 17 13
08 10 10
09 14 11
10 15 11
11 14 8
12 13 11
13 15 11
14 13 8
15 13 10
16 11 10
;
PROC TTEST DATA=D1 H0=0 ALPHA=0.05;
PAIRED AFTNOON*MORNING;
RUN;
Chi-square Test of the Difference between Observed and Expected
Frequencies
Example: The expected proportions of white, brown and pied rabbits
in a population are 0.36, 0.48 and 0.16 respectively. In a sample of 400
rabbits there were 140 white, 240 brown and 20 pied. Are the
proportions in that sample of rabbits different than expected?

DATA color;
INPUT color $ number;
DATALINES;
white 140
brown 240
pied 20
;
PROC FREQ DATA=color;
WEIGHT number;
TABLES color/ TESTP=(36 48 16);
RUN;
Hypothesis Test of Differences among
Proportions from Several Populations
Example: Are the proportions of cows with mastitis significantly
different among three farms? The number of cows on farms A, B and C
are 96, 132 and 72, respectively. The number of cows with mastitis on
farms A, B and C are 36, 29 and 10, respectively.

DATA a;
INPUT farm $ mastitis $ number;
DATALINES;
A YES 36
A NO 60
B YES 29
B NO 103
C YES 10
C NO 62
;
PROC FREQ DATA=a ORDER=DATA;
WEIGHT number;
TABLES farm*mastitis/ CHISQ;
RUN;
Correlation
Example: Is there a linear association between weight and heart girth
in this herd of cows?
Weight was measured in kg and heart girth in cm on 10 cows:

Cow 1 2 3 4 5 6 7 8 9 10
Weight (y): 641 620 633 651 640 666 650 688 680 670
Heart girth (x): 205 212 213 216 216 217 218 219 221 226

DATA cows;
INPUT No weight h_girth @@;
DATALINES;
1 641 205 2 620 212 3 633 213 4 651 216 5 640 216
6 666 217 7 650 218 8 688 219 9 680 221 10 670 226
;
PROC CORR;
VAR weight h_girth;
RUN;
Simple Linear Regression
DATA cows;
INPUT No weight h_girth @@;
DATALINES;
1 641 205 2 620 212 3 633 213 4 651 216 5 640 216
6 666 217 7 650 218 8 688 219 9 680 221 10 670 226
;
PROC REG;
MODEL weight = h_girth /;
RUN;
Multiple Linear Regression
Example: Estimate the regression of weight on heart girth and height, and its
error
variance, from the data of six young bulls given in the following table:
Bull: 1 2 3 4 5 6 7
Weight, kg (y): 480 450 480 500 520 510 500
Heart girth, cm (x1): 175 177 178 175 186 183 185
Height, cm (x2): 128 122 124 128 131 130 124

DATA bulls;
INPUT NO weight h_girth height;
DATALINES;
1 480 175 128
2 450 177 122
3 480 178 124
4 500 175 128
5 520 186 131
6 510 183 130
7 500 185 124
;
PROC GLM;
MODEL weight=h_girth height ;
RUN;
Stepwise Regression Model
DATA bull;
INPUT weight1 x2 x3 x4 x5 x6 x7 x8 x9;
DATALINES;

19.3 46 65 45 47 22 18 13 17
22.5 46 69 50 51 24 21 14 17
19 42 60 45 46 23 22 13 17
18.6 52 61 47 48 22 20 14 15
20.2 49 68 46 48 23 21 12 13
23.6 56 67 48 49 24 21 12 15
26.4 49 70 51 54 25 23 16 18
30.8 52 71 52 55 26 24 17 21
21.8 46 63 44 45 23 20 15 19
26.2 49 69 50 54 25 24 14 19
24.4 45 68 45 46 25 21 15 18
28.1 51 71 51 52 26 24 15 17
24.4 48 68 50 52 22 21 14 20
23 48 69 53 54 25 22 15 18
25.1 46 70 51 52 24 21 14 17
26.6 49 70 48 50 24 22 15 18
23.5 46 67 42 48 23 21 16 19
29.2 46 71 53 54 26 23 15 20
25.2 46 68 47 50 25 22 14 17
22.9 50 65 46 47 24 22 14 16
30.3 50 71 50 51 25 24 13 20
23.1 44 69 49 48 24 22 15 17
30.5 48 71 50 55 24 23 15 19
28.6 49 74 46 48 24 20 16 19
19.5 44 65 48 49 23 21 13 15
22.8 45 68 50 51 23 21 14 17
26.1 48 69 49 50 26 22 16 19
28.5 49 67 50 52 24 23 14 19
24.1 46 70 43 46 25 23 14 20
22.7 44 66 50 52 23 24 14 18
28.8 48 73 51 54 27 25 15 20
27.5 53 67 51 49 27 26 15 16
22.4 52 71 50 47 24 21 14 15
24.9 52 69 48 49 22 20 13 14
26.8 54 73 49 50 24 22 14 15
24.7 54 68 46 47 24 21 12 14
27 55 71 47 48 26 24 14 17
24.1 53 68 46 47 24 23 14 15
25.6 51 71 48 49 23 22 14 14
24.8 55 68 49 50 23 21 14 14
22.1 52 65 48 46 23 25 13 14
18.7 50 61 45 46 20 19 12 12
18.9 50 64 47 50 21 18 13 13
17.1 50 59 41 41 20 18 13 15
21 52 66 47 46 23 22 13 15
18.3 49 60 44 45 22 20 11 13
17.2 52 57 42 43 22 16 12 13
17.5 50 61 42 43 21 20 13 12
23.4 53 67 47 48 24 23 14 18
17.4 45 63 45 46 22 19 13 15
20.3 48 66 47 49 23 18 14 17
23.3 51 73 49 49 24 22 14 18
18.6 44 65 44 45 23 19 14 15
20.7 54 64 45 47 21 20 13 15
21.8 49 72 51 54 24 22 12 18
20.6 55 65 48 50 23 19 14 17
20.2 50 70 48 48 23 29 15 19
22.8 52 68 50 51 24 23 17 21
22.8 54 65 49 50 23 24 16 19
23.4 51 70 49 51 25 23 15 18
27.6 51 76 48 51 25 24 18 22
26.7 52 76 50 53 25 23 17 17
24 53 64 50 51 26 22 13 16
28 58 68 48 50 23 20 15 17
20.4 52 66 42 43 22 19 12 17
26.9 55 67 53 54 24 22 15 18
25.3 51 66 51 54 24 23 15 16
19.6 54 63 46 47 23 17 15 16
24.4 55 65 49 50 24 23 14 15
20.7 56 66 47 48 22 21 14 15
22 51 66 44 45 23 21 15 19
22.2 55 64 48 48 25 22 13 15
18.7 47 65 42 43 23 20 15 16
22.3 54 70 50 52 24 22 15 16
24.2 52 71 52 54 25 22 16 18
21.9 52 72 44 45 24 21 17 18
21.1 51 71 51 52 25 23 14 16
22.6 52 73 48 50 25 21 16 19
22.6 53 69 47 50 24 21 16 17
21.4 53 71 49 50 25 22 15 17
23.1 53 71 53 56 26 24 15 19
19.9 46 68 51 52 25 24 14 21
23.6 54 66 48 52 24 22 15 17
26.4 52 76 52 53 26 24 15 17
30.6 54 79 49 54 27 25 17 20
25 51 69 51 54 25 25 15 20
;
PROC REG DATA=bull;
MODEL weight1= x2 x3 x4 x5 x6 x7 x8 x9/ SSE CP AIC SELECTION=CP ;
RUN;

You might also like