Sample 35171: Histogram with Normal and Kernel Density Curves
This sample uses the Graph Template Language (GTL) to produce a distribution plot. It uses a two-row lattice layout. The upper cell contains a histogram with normal and kernel density curves, a legend, and a table. The lower cell contains a horizontal box plot and a band plot.
This sample uses the Graph Template Language (GTL) to produce a distribution plot. It uses a two-row lattice layout. The upper cell contains a histogram with normal and kernel density curves, a legend, and a table. The lower cell contains a horizontal box plot and a band plot.
proc template;
define statgraph SGF2009.Histogram;
begingraph / designwidth=600px designheight=400px;
entrytitle "Distribution of Vehicle Horsepower";
layout lattice / rowweights=(.85 .15) columndatarange=union rowgutter=2px;
columnaxes;
columnaxis / display=(ticks tickvalues label) label='Horsepower';
endcolumnaxes;
layout overlay / yaxisopts=(offsetmin=.03 griddisplay=auto_on);
layout gridded / columns=2 autoalign=(topleft) border=true
opaque=true backgroundcolor=GraphWalls:color;
entry halign=left "N"; entry halign=left eval(strip(put(n(horsepower),12.0)));
entry halign=left "Mean"; entry halign=left eval(strip(put(mean(horsepower),12.2)));
entry halign=left "Std Dev"; entry halign=left eval(strip(put(stddev(horsepower),12.2)));
endlayout;
histogram horsepower / scale=percent primary=true binaxis=false nbins=20 datatransparency=0.4;
densityplot horsepower / normal( ) name="norm" legendlabel="Normal";
densityplot horsepower / kernel( ) name="kern" legendlabel="Kernel" lineattrs=graphdata2(thickness=2px);
fringeplot horsepower / datatransparency=.7 fringeheight=5px;
discretelegend "norm" "kern" "band" / location=inside across=1 autoalign=(topright) opaque=true;
endlayout;
layout overlay;
bandplot y=horsepower limitlower=eval(lclm(horsepower)) limitupper=eval(uclm(horsepower)) /
yaxis=y2 extend=true display=(fill) fillattrs=GraphConfidence2
name="band" legendlabel="95% Confidence";
boxplot y=horsepower / orient=horizontal primary=true boxwidth=.9 datatransparency=0.4;
endlayout;
endlayout;
endgraph;
end;
run;
ods listing close;
ods html style=default image_dpi=100 file='histogram.html' path='.';
ods graphics / reset imagename="GTLHandout_Histogram" imagefmt=gif;
proc sgrender data=sashelp.cars template=SGF2009.Histogram ;
run;
ods html close;
ods listing;
This sample uses the Graph Template Language (GTL) to produce a histogram with normal and kernel density curves,
| Type: | Sample |
| Topic: | SAS Reference ==> Procedures ==> SGRENDER Query and Reporting ==> Creating Reports ==> Graphical ==> Graph Template Language (GTL)
|
| Date Modified: | 2009-03-19 10:29:49 |
| Date Created: | 2009-03-17 16:58:18 |
Operating System and Release Information
| SAS System | SAS/GRAPH | z/OS | 9.2 TS1M0 | |
| Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
| Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
| Microsoft® Windows® for x64 | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
| Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
| Microsoft Windows XP Professional | 9.2 TS1M0 | |
| Windows Vista | 9.2 TS1M0 | |
| 64-bit Enabled AIX | 9.2 TS1M0 | |
| 64-bit Enabled HP-UX | 9.2 TS1M0 | |
| 64-bit Enabled Solaris | 9.2 TS1M0 | |
| HP-UX IPF | 9.2 TS1M0 | |
| Linux | 9.2 TS1M0 | |
| Linux for x64 | 9.2 TS1M0 | |
| OpenVMS on HP Integrity | 9.2 TS1M0 | |
| Solaris for x64 | 9.2 TS1M0 | |