*Grouping a Scatter Plot;
proc sgplot data=sashelp.class;
scatter x=height y=weight / group=sex;
run;
*Plotting Three Series;
proc sgplot data=sashelp.stocks
(where=(date >= "01jan2000"d and stock = "IBM"));
title "Stock Trend";
series x=date y=close;
series x=date y=low;
series x=date y=high;
run;
*Adding Prediction and Confidence Bands to a Regression Plot;
proc sgplot data=sashelp.class;
reg x=height y=weight / CLM CLI;
run;
*Adding a Prediction Ellipse to a Scatter Plot;
proc sgplot data=sashelp.iris;
title "Iris Petal Dimensions";
scatter x=petallength y=petalwidth;
ellipse x=petallength y=petalwidth;
keylegend / location=inside position=bottomright;
run;
*Creating Lines and Bands from Pre-Computed Data;
proc sgplot data=sashelp.classfit;
title "Fit and Confidence Band from Precomputed Data";
band x=height lower=lower upper=upper /
legendlabel="95% CLI" name="band1";
band x=height lower=lowermean upper=uppermean /
fillattrs=GraphConfidence2
legendlabel="95% CLM" name="band2";
scatter x=height y=weight;
series x=height y=predict / lineattrs=GraphPrediction
legendlabel="Predicted Fit" name="series";
keylegend "series" "band1" "band2" / location=inside position=bottomright;
run;
*Adding Statistical Limits to a Dot Plot;
proc sgplot data=sashelp.class(where=(age<16));
dot age / response=height stat=mean
limitstat=stddev numstd=1;
run;
*Combining Histograms with Density Plots;
proc sgplot data=sashelp.heart;
title "Cholesterol Distribution";
histogram cholesterol;
density cholesterol;
density cholesterol / type=kernel;
keylegend / location=inside position=topright;
run;
*Creating a Horizontal Box Plot;
proc sgplot data=sashelp.heart;
title "Cholesterol Distribution by Weight Class";
hbox cholesterol / category=weight_status;
run;
*Creating a Bar-Line Chart;
proc sgplot data=sashelp.stocks (where=(date >= "01jan2000"d
and date <= "01jan2001"d
and stock = "IBM"));
title "Stock Volume vs. Close";
vbar date / response=volume;
vline date / response=close y2axis;
run;