In: Statistics and Probability
5. Suppose you have a data set:
Experiment 56 880
Control 15 398
Experiment 30 479
Control 18 293
Experiment 35 365
Control 22 984
Control 13 230
Control 20 432
Experiment 34 560
Variables are treatment, weight (g), area (m2), please create a SAS program that:
(A). Reading the data and create a SAS data set;
(b). Create a new variable wt_per_area, using wt_per_area=weight/area and change the unit of weight from g to kg;
(c). Sort the data set by treatment;
(d). Calculate the mean, standard error of weight, area and wt_per_area;
(e). Calculate the mean and standard error for treatment=”experiment” and “control”.
SAS code:
/*create a SAS data set*/
data avi;
input treatment$1-10 weight area;
datalines;
Experiment 56 880
Control 15 398
Experiment 30 479
Control 18 293
Experiment 35 365
Control 22 984
Control 13 230
Control 20 432
Experiment 34 560
;
run;
proc print data=avi;
run;
/*(b)new variable wt_per_area, using wt_per_area=weight/area and
change the unit of weight from g to kg*/
data avi3;
set avi;
wt_per_area=weight/(area*1000);
run;
proc print data=avi3;
run;
/*(c)Sort the data set by treatment*/
proc sort data=avi3 out=avi3_sort;
by treatment;
proc print data=avi3_sort;
run;
/*(d)mean, standard error of weight, area and wt_per_area*/
proc means data=avi3_sort;
run;
/*(e) mean and standard error for treatment=”experiment” and
“control”*/
proc means data=avi3_sort;
by treatment;
run;
SAS output:
Obs | treatment | weight | area |
---|---|---|---|
1 | Experiment | 56 | 880 |
2 | Control | 15 | 398 |
3 | Experiment | 30 | 479 |
4 | Control | 18 | 293 |
5 | Experiment | 35 | 365 |
6 | Control | 22 | 984 |
7 | Control | 13 | 230 |
8 | Control | 20 | 432 |
9 | Experiment | 34 | 560 |
The SAS System |
Obs | treatment | weight | area | wt_per_area |
---|---|---|---|---|
1 | Experiment | 56 | 880 | .000063636 |
2 | Control | 15 | 398 | .000037688 |
3 | Experiment | 30 | 479 | .000062630 |
4 | Control | 18 | 293 | .000061433 |
5 | Experiment | 35 | 365 | .000095890 |
6 | Control | 22 | 984 | .000022358 |
7 | Control | 13 | 230 | .000056522 |
8 | Control | 20 | 432 | .000046296 |
9 | Experiment | 34 | 560 | .000060714 |
The SAS System |
Obs | treatment | weight | area | wt_per_area |
---|---|---|---|---|
1 | Control | 15 | 398 | .000037688 |
2 | Control | 18 | 293 | .000061433 |
3 | Control | 22 | 984 | .000022358 |
4 | Control | 13 | 230 | .000056522 |
5 | Control | 20 | 432 | .000046296 |
6 | Experiment | 56 | 880 | .000063636 |
7 | Experiment | 30 | 479 | .000062630 |
8 | Experiment | 35 | 365 | .000095890 |
9 | Experiment | 34 | 560 | .000060714 |
The SAS System |
The MEANS Procedure
Variable | N | Mean | Std Dev | Minimum | Maximum | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
The SAS System |
The MEANS Procedure
treatment=Control
Variable | N | Mean | Std Dev | Minimum | Maximum | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|
treatment=Experiment
Variable | N | Mean | Std Dev | Minimum | Maximum | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|
|
|
|