




























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Material Type: Notes; Professor: Bailer; Class: Statistical Programming; Subject: Statistics; University: Miami University-Oxford; Term: Fall (First Sem) 2008;
Typology: Study notes
1 / 36
This page cannot be seen from the preview
Don't miss anything!





























Producing High-Resolution Graphics using SAS/Graph
data nitrofen; infile '\Muserver2\USERS\B\BAILERAJ\public.www\classes\sta402\data\ch2- dat.txt' firstobs=16 expandtabs missover pad ; input @9 animal 2. @33 brood2 2. @41 brood3 2. @49 total 2.; @17 conc 3. @25 brood1 2. ods rtf bodytitle; proc chart; title "proc CHART"; hbar total / subgroup=conc; run; proc gchart; title "proc GCHART"; hbar total / subgroup=conc; run; proc plot; title "proc PLOT"; plot brood1conc="1" brood2conc="2" brood3conc="3" / run;^ overlay vaxis=0 to 20 by 2; proc gplot; title "proc GPLOT"; plot brood1conc="1" brood2conc="2" brood3conc="3" / overlay vaxis=0 to 20 by 2; run; ods rtf close;
Midpoint (^) ‚ Freq Freq Percent Percent 0 ‚33 ‚ 1 1 2.00 2. 6 ‚223333333333333333 ‚ 9 10 18.00 20. 12 ‚2222 ‚ 2 12 4.00 24. 18 ‚22222233 ‚ 4 16 8.00 32. 24 ‚00881111222222 ‚ 7 23 14.00 46. 30 ‚0000000088888888111111111111111122 ‚ 17 40 34.00 80. 36 ‚00000000008888888888 ‚ 10 50 20.00 100. Šƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒƒˆƒƒ 2 4 6 8 10 12 14 16 Frequency Symbol conc Symbol conc Symbol conc 02 2350 83 31080 1 160
proc GCHART
conc 0 80 160 235 310
FREQ. FREQ.CUM. PCT. CUM.PCT. 1 1 2 2 9 10 18 20 2 12 4 24 4 16 8 32 7 23 14 46 17 40 34 80 10 50 20 100
total MIDPOINT
36
30
24
18
12
6
0
FREQUENCY
0 2 4 6 8 10 12 14 16 18
brood
0
2
4
6
8
10
12
14
16
18
20
conc
0 100 200 300 400
1
1111111 1
(^1 )
1
1
1
1 1 1
11 1
1111111 1
1 1
1111 1
11 111
1
111111
2 222
(^22) 22 22 2
2222 22
222 22 2
22
(^22) 2
22 2 2
2
2
2
22
2
2
2 2222
2
22222
3
3
3 3333 (^33)
3
33
3 (^33) (^33) 3
33 33
3 3
(^333) 333
(^33)
3
3
3
3 3
3 3
3
3333333333
data manatee_deaths; input year nboats manatees @@; 77 447 13^ datalines; 78 460 21 79 481 24 80 498 16 81 513 24 85 585 33 82 512 2086 614 33 83 526 1587 645 39 84 559 3488 675 43 89 711 50 ; 90 719 47 ODS RTF bodytitle; ODS graphics on; proc reg data=manatee_deaths; title ‘Number of Manatees killed regressed on the number of boats registered in Florida’; model manatees = nboats; run; ODS graphics off; ODS RTF CLOSE;
data mrexample; * Lunneborg (1994) - body weight brain example; input species $ bodywt brainwt @@; logbody = log10(bodywt); logbrain = log10(brainwt); * transform the weights; idino = 0; if (species="diplodoc" or species="tricerat" or species="brachios") then * define the indicator of dinosaurs; idino=1;
beaver 1.35 8.10 cow 465.00 423.00 wolf 36.33 119.50 goat 27.66 115.00^ datalines; guipig 1.04 5.50 diplodocus 11700.00 50.00 asielephant 2547.00 4603.00 donkey 187.10 419.00 horse 521.00 655.00 potarmonkey 10.00 115. cat 3.30 25.60 giraffe 529.000 680.00 gorilla 207.00 406.00 human 62.00 1320.00 afrelephant 6654.00 5712.00 triceratops 9400.00 70. rhemonkey 6.80 179.00 kangaroo 35.00 56.00 hamster 0.12 1.00 mouse 0.023 0.40 rabbit 2.50 12.10 sheep 55.50 175. jaguar 100.00 157.00 chimp 52.16 440.00 brachiosaurus 87000.00 154.50 rat 0.28 1.90 mole 0.122 3.00 pig 192.00 180 ;
proc reg; title2 ‘Dinosaurs fitted with potentially different INTERCEPTS’; * different intercepts;
run;^ model logbrain=logbody idino; ODS graphics off; ODS RTF CLOSE;
retain num_heads 0; call streaminit(1234567); do itoss = 1 to 1200; outcome = RAND('Bernoulli', 0.50); num_heads = num_heads + (outcome=1); probability_heads = num_heads / itoss ; end;^ output; goptions reset=global; symbol interpol=join; axis1 order=0.35 to 0.65 by 0.05 label=(angle=90 "Estimated Pr(HEADS)"); axis2 order=0 to 500 by 50 label=("Number of simulated data points"); ods rtf bodytitle; proc gplot; plot probability_heads*itoss / vaxis=axis1 haxis=axis2; run; ods rtf close;
Estimated Pr(HEADS)
Number of simulated data points
0 50 100 150 200 250 300 350 400 450 500
Estimated Pr(HEADS)
Number of simulated data points
0 50 100 150 200 250 300 350 400 450 500
Estimated Pr(HEADS)
Number of simulated data points
0 50 100 150 200 250 300 350 400 450 500
Long-term relative frequency of HEADS=0.
/* generate a profile of [OR, log(OR)] values */ data or_stuff; do or=0.01 to 5 by .01; logor = log(or); end;^ output; goptions reset=global; * often a good idea, especially if doing lot of graphs;
/* interpolate btwn [OR, log(OR)] values and set up axes */ symbol interpol=join; axis1 label=("Odds Ratio"); axis2 label=(angle=90 "Log(Odds Ratio)" );
/* set up annotate data set with arrows and text to illustrate the CI idea / data myanno; length function $ 5 text $ 7; retain xsys "2" ysys "2" function SE; SE = .2; function="move"; x=2; y=-5; output; function="arrow"; x=2; y=log(2); line=2; output; from OR to logOR; function="arrow"; x=.01; y=log(2); output; * back to y-axis; function="draw"; function="arrow"; x=exp(log(2)+ 1.96SE); y=log(2)+ 1.96SE; output; x=.01; y=log(2)+ 1.96SE; output; * upper CI; function="arrow"; x=exp(log(2)+ 1.96SE); y=-4.5; output; function="move"; function="draw"; x=.01; y=log(2); output;x=.01; y=log(2)- 1.96SE; output; * lower CI; function="arrow"; x=exp(log(2)- 1.96SE); y=log(2)- 1.96SE; output; function="arrow"; x=exp(log(2)- 1.96SE); y=-4.5; output; function="label"; x=exp(log(2)- 1.96SE); y=-4.75; text="LCL OR"; output; x=exp(log(2)+ 1.96SE); y=-4.75; text="UCL OR"; output; x=2.2; y=-2; text="Step 1 "; output; x=1; y=log(2) + .25; text=" Step 2 "; output; x=0.5; y= log(2)- 1.96SE - .25; text="Step 3a"; output; x=0.5; y= log(2)+ 1.96SE + .25; text="Step 3b"; output; x=3.2; y=-2; text="Step 4a"; output;
text;^ x=1.2; y=-2; text="Step 4b";^ position="<"; output; * right justify /* render the figure with annotation */ ods rtf bodytitle; proc gplot data=or_stuff; plot logor * or / annotate=myanno haxis=axis1 vaxis=axis2;
ods rtf close;^ run;
/* load the nitrofen data until a SAS data set / data nitrofen; infile '\Muserver2\USERS\B\BAILERAJ\public.www\classes\sta402\data\ch2- dat.txt' firstobs=16 expandtabs missover pad ; input @9 animal 2. @17 conc 3. @25 brood1 2. @33 brood2 2. @41 brood3 2. @49 total 2.; jconc = conc + 15ranuni(0) - 7.5; * adding a little jitter to see points; proc print data=nitrofen; run; proc means data=nitrofen; var total; * obtain means that are hard coded below; class conc; run;
/* FIGURE 1: Scatterplot with superimposed segments at group means / / set up axes and suppress the x-axis tick marks and labels / goptions reset=global; axis1 label=(angle=90 'Total number of young (3 broods)'); axis2 label=('Nitrofen Concentration') order=(-20 to 340 by 20) minor=none major=none v=none; / define annotate data set to draw mean segments and nitrofen conc. / data myanno; length function $ 5 text $ 3; retain xsys '2' ysys '2'; function="label"; x=0; y=2; text="0"; output; function="label"; x=80; y=2; text="80"; output; function="label"; x=160; y=2; text="160"; output; function="label"; x=235; y=2; text="235"; output; function="label"; x=310; y=2; text="310"; output; function='move'; x= 0 - 15; y=31.4; output; * conc=0; function='draw'; x= 0 + 15; function='move'; x= 80 - 15; y=31.4; size=2; output;y=31.5; output; * conc=80; function='draw'; x= 80 + 15; function='move'; x= 160 - 15; y=31.5; size=2; output;y=28.3; output; * conc=160; function='draw'; x= 160 + 15; function='move'; x= 235 - 15; y=28.3; size=2; output;y=17.2; output; * conc=235; function='draw'; x= 235 + 15; function='move'; x= 310 - 15; y=17.2; size=2; output;y=6.0; output; * conc=310; function='draw'; x= 310 + 15; y=6.0; size=2; output; ods rtf bodytitle; / generate figure 1 / proc gplot data=nitrofen; plot totaljconc / vaxis=axis1 haxis=axis2 annotate=myanno; run; /* FIGURE 2: Scatterplot with superimposed boxplots */
/* set up axes and suppress the x-axis tick marks and labels / / and request boxplot interpolations */ goptions reset=global; axis1 label=(angle=90 'Total number of young (3 broods)'); axis2 (^) minor=none major=none v=none;label=('Nitrofen Concentration') order=(-20 to 340 by 20) symbol1 i=none v=dot color=black; symbol2 interpol=box v=none color=black bwidth=8;
/* annotate data set for the concentration labels / data myanno2; length function $ 5 text $ 3; retain xsys '2' ysys '2'; function="label"; x=0; y=2; text="0"; output; function="label"; x=80; y=2; text="80"; output; function="label"; x=160; y=2; text="160"; output; function="label"; x=235; y=2; text="235"; output; function="label"; x=310; y=2; text="310"; output; / generate figure 2 proc gplot data=nitrofen; */
;^ plot totaljconc totalconc / overlay anno=myanno2 vaxis=axis1 haxis=axis ods rtf close;^ run;