Reputation: 37
I am running a proc sgplot in SAS to create a histogram. Y-axis: Number of people, X-Axis: Count of Miles. The problem is the histogram is displaying the data using 30+ bars of very small x-axis intervals. I want only 10 bars to display in the histogram. Is there a simple feature I can add to the code to limit the histogram to display only 10 bars? Code below:
proc sgplot data= miles;
title "Cumulative Miles Driven by Number of Individuals"
histogram CumulativeMiles/scale= count
fillattrs=(color=blue);
xaxis values= (0 to 1000 by 100)
label= "Cumulatve Miles Driven"
yaxis values= (0 to 50000 by 10000)
label= "Number of Individuals";
run;
Upvotes: 0
Views: 807
Reputation: 21274
NBINS=10
option on the HISTOGRAM
statement.
NBINS=numeric-value specifies the number of bins. The system determines the BINWIDTH= value. The bins always span the range of the data.
The procedure attempts to produce tick values that are easily interpreted (for example, 5, 10, 15, 20). The procedure sometimes adjusts the location of the first bin and the bin width accordingly. As a result, the number of bins shown in the plot might not exactly match the number specified with NBINS=.
Or specify the BINWIDTH and/or BINSTART options. See the plot options here.
Upvotes: 1