PowerPoint Slides (pdf)

advertisement
SAS Workshop
Introduction to SAS
Programming
DAY 2 SESSION II
Iowa State University
May 10, 2016
Sample SAS Program B8
data survival;
input Poison 1. @;
do Drug=1 to 4;
input Time 3.2 @;
output;
end;
datalines;
1 31 82 43 45
1 45110 45 71
1 46 88 63 66
1 43 72 76 62
2 36 92 44 56
2 29 61 35102
2 40 49 31 71
2 23124 40 38
3 22 30 23 30
3 21 37 25 36
3 18 38 24 31
3 23 29 22 33
;
title1 "Analysis of Survival Time data";
title2 "Poison X Drug Interaction Plot";
proc sgplot data=survival;
vline Poison/response=Time stat=mean group=Drug markers;
run;
Sample SAS Program B9
libname lib9
"U:\Documents\SAS_Workshop_Spring2016\Data\";
data lib9.biology;
infile "U:\Documents\SAS_Workshop_Spring2016\Data\biology.txt";
input Id Sex $ Age Year Height Weight;
run;
title "Regression of Weight on Height: Biology class data";
proc sgplot data=lib9.biology;
reg x=Height y=Weight/CLM CLI;
run;
Sample SAS Program B10
libname mylib "U:\Documents\SAS_Workshop_Spring2016\Data\";
proc format;
value ing 1 = 'Low Income'
2 = 'Middle Income'
3 = 'High Income';
run;
title “Horizontal Bar Chart of Miles of Primary Highways”;
proc sgplot data=mylib.fueldat;
hbar Incomgrp/response=Roads stat=mean group=Taxgrp;
keylegend / title="Fuel Tax" location=outside position=bottom;
format Incomgrp ing.;
run;
title “Vertical Bar Chart Fuel Use by Income Group for each Fuel Tax Group”;
proc sgpanel data=mylib.fueldat;
panelby Taxgrp;
vbar Incomgrp/response=Fuel stat=mean fillattrs=(color=bisque);
format Incomgrp ing.;
run;
Sample SAS Program B11
libname mylib "U:\Documents\SAS_Workshop_Spring2016\Data\";
proc sgpanel data=mylib.fueldat;
title "Dot Plot of Fuel Use by Fuel Tax";
panelby Taxgrp/layout=rowlattice;
dot State/response=Fuel categoryorder=respasc;
run;
Other SAS Procs also produce SAS
Graphics, either by Default or by Request
 Examples of such procedures are proc reg and proc univariate
 While the user requests for a particular plot in a procedure like
proc univariate e.g., using a statements such as histogram or
probplot, other procedures like proc reg produce a selected set of
graphics by default.
 The default graphical output in proc reg consists of a fit diagnostics
panel, a residual plot, and a fit plot.
 These plots are integrated with the output with tables of statistics
produced by proc reg
 The results are displayed in the HTMLBlue style which is the
default style for all ODS output.
Sample SAS Program B12
data muscle;
input x y;
label x=‘Age’ y=‘Muscle Mass’;
datalines;
71 82
64 91
……….
49 105
78 77
;
proc reg data=muscle;
model y = x/r;
title ‘Linear Regression Analysis of Muscle Mass Data’;
run;
Download