FOCUS AREAS

Graphics

Histogram
Histogram
Base SAS: ODS Graphics Procedure: SGPLOT

/* Open the LISTING destination and assign the LISTING style to the graph */ 
ods listing style=listing;
ods graphics / width=5in height=2.81in;
title 'Distribution of Mileage';

/* Run PROC SGPLOT on data SASHELP.CARS, excluding hybrid vehicles from the analysis */
proc sgplot data=sashelp.cars(where=(type ne 'Hybrid'));
  /* Generate a histogram with normal and kernal density curves */
  histogram mpg_city;
  density mpg_city / lineattrs=(pattern=solid);
  density mpg_city / type=kernel lineattrs=(pattern=solid);

  /* position the legend inside the top-right corner of the plot area */
  keylegend / location=inside position=topright across=1;

  /* Remove the axis offset for minimum Y valus so that Y=0 aligns with the X axis */
  yaxis offsetmin=0 grid;
run;