* a good page of SGPLOT graphs with code is found at the SAS website: http://support.sas.com/sassamples/graphgallery/PROC_SGPLOT.html; libname herc 'S:\Courses\stat-renaes\Stat404'; * Scatterplot PROC GPLOT; goptions reset=all; proc gplot data=herc.budget; plot Yr2007*Month; format Yr2007 dollar12.; title 'Plot of Budget by Month'; run; quit; * Scatterplot PROC SGPLOT; goptions reset=all; proc sgplot data=herc.budget; scatter x=Month y=Yr2007; format Yr2007 dollar12.; title 'Plot of Budget by Month'; run; quit; * Line plot (time series) PROC GPLOT; goptions reset=all; proc sgplot data=herc.budget; series x=Month y=Yr2007; label Yr2007='Budget'; format Yr2007 dollar12.; title 'Plot of Budget by Month'; symbol1 v=dot i=join cv=red ci=blue; run; quit; * Line plot (time series) PROC SGPLOT; goptions reset=all; proc sgplot data=herc.budget; series x=Month y=Yr2007; label Yr2007='Budget'; format Yr2007 dollar12.; title 'Plot of Budget by Month'; run; quit; * example for SGPLOT histograms and scatterplot; data handwashing; input counts method $; cards; 74 H20 84 Soap 70 AbS 51 Spray 135 H20 51 Soap 164 AbS 5 Spray 102 H20 110 Soap 88 AbS 19 Spray 124 H20 67 Soap 111 AbS 18 Spray 105 H20 119 Soap 73 AbS 58 Spray 139 H20 108 Soap 119 AbS 50 Spray 170 H20 207 Soap 20 AbS 82 Spray 87 H20 102 Soap 95 AbS 17 Spray ; run; proc sgplot data=handwashing; histogram counts; density counts; run; quit; * Boxplots; proc sgplot data=handwashing; title "Box Plot: Category = Method"; vbox counts / category=method; run; title "Box Plot: Group = Method"; vbox horsepower / group=Method; run; quit; proc sgplot data=sashelp.cars; title "Box Plot: Category = Cylinders"; vbox horsepower / category=cylinders; run; title "Box Plot: Group = Cylinders"; vbox horsepower / group=cylinders; run; quit; * here is a basic contour plot (surface area map); goptions reset=all border; title "Lake Data"; footnote j=r "GCTLAKE"; proc gcontour data=sashelp.lake; plot length*width=depth; run; quit; * another contour with extras; goptions reset=all border; data pollen; input Week Workdays Pollen @@; datalines; 1 1 50 1 2 96 1 3 28 1 4 94 1 5 124 2 1 204 2 2 153 2 3 43 2 4 21 2 5 60 3 1 37 3 2 23 3 3 57 3 4 21 3 5 65 4 1 8 4 2 144 4 3 22 4 4 141 4 5 95 ; run; title1 "The Amount of Pollen Particles in a Cubic Meter of Air"; footnote1 j=r "GCTNLVEL"; axis1 order=(1 to 4 by 1); proc gcontour data=pollen; plot week*workdays=pollen/ hminor=0 llevels= 2 20 21 33 25 41 name="GCTNLVEL" nlevels=6 vaxis=axis1 vminor=0; run; quit; * and another even fancier contour plot; goptions reset=all border; data swirl; do x= -5 to 5 by 0.25; do y= -5 to 5 by 0.25; if x+y=0 then z=0; else z=(x*y)*((x*x-y*y)/(x*x+y*y)); output; end; end; run; title1 "Line Contour Levels"; footnote1 j=r "GCTPATR1"; proc gcontour data=swirl; plot y*x=z; run; quit; title1 "Pattern Contour Levels"; footnote j=r "GCTPATR2"; proc gcontour data=swirl; plot y*x=z / ctext=green coutline=gray pattern; run; quit; title "Contour Plot with Joined Cells"; footnote j=r "GCTPATR3"; axis1 label=none value=("-5" '' "0" '' "5") color=red width=3; axis2 label=none value=("-5" '' "0" '' "5") color=red width=3; legend1 frame; proc gcontour data=swirl; plot y*x=z / haxis=axis1 join legend=legend1 pattern vaxis=axis2; run; quit;