forked from burakbayramli/books
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbarleyyields.sas
70 lines (53 loc) · 2.11 KB
/
barleyyields.sas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/* Analysis of barley yields data set */
/* This SAS program illustrates how to create side-by-side box plots
and to compute some summary statistics */
title 'Comparison of barley yields';
options nodate nonumber noovp;
data barley;
infile 'barleyyields.txt' firstobs=15 expandtabs;
input obs y1980 y1982 y1986; /* input the three yields */
/* now to structure the data into two columns. One column has the year, and the second
column has the yield. Eliminate any missing values as these are artefacts of the
data file */
year = 1980; yield= y1980; if obs < 51 then output;
year = 1982; yield= y1982; if obs < 41 then output;
year = 1986; yield= y1986; if obs < 56 then output;
keep year yield;
proc print data=barley (obs=20);
title2 'part of the raw data';
proc tabulate data=barley; /* get some simple summary statistics */
title2 'some simple summary statistics';
class year;
var yield;
table year, yield*(n*f=5.0 mean*f=7.1 std*f=5.1) / rts=20;
run;
/* set up the graphics file */
filename gsasfile 'barleyyields.ps';
goptions device=ps300 gaccess=sasgaedt
gsflen=80 gsfname=gsasfile gsfmode=replace rotate=landscape
colors=(black);
/* create side-by-side dot plots with some jittering of the data points */
data plotdata1;
set barley;
year = year + rannor(2343)*.05; /* add random noise to the year variable */
proc gplot data=plotdata1;
title2 'a side-by-side dot plot with data points jittered';
axis1 label=(a=90 r=0 'Yield (g/400 m2)') ;
axis2 label=('Year') order=1975 to 1990 by 1;
plot yield*year / vaxis=axis1 haxis=axis2;
run;
/* create side-by-side box plots */
proc sort data=barley; by year;
goptions gsfmode=append; /* allow more plots to be appended */
proc boxplot data=barley;
title2 'side-by-side box plots';
plot yield*year;
run;
/* create histograms of the three years */
proc gchart data=barley;
title2 'histograms of the yields';
vbar yield / midpoints=130 to 390 by 20 type=percent group=year space=0;
run;
x 'ps2pdf barleyyields.ps barleyyields.pdf';
x 'chmod o+r *.pdf';
x '/usr/bin/rm *.ps';