<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic how to set bin boundaries and display count in sgplot histogram in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-bin-boundaries-and-display-count-in-sgplot-histogram/m-p/78542#M2925</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a distribution histogram that has bins that start on the grid lines (as opposed to the default where the grid lines are the midpoint of each bin). Is there a way to do this with the options?&amp;nbsp; Also, is there a way to have the histogram display the count for each individual bin? This is the code I have written so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data = dataset noautolegend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; histogram variable /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binstart = 60 binwidth = 5 scale =count;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refline = 140 / &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; axis = xlineattrs = (color = red thickness =2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xaxis label = 'abc' grid values = (60 to 220 by 5);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final product I am hoping for is a histogram that has an x axis that starts at 60 and has grid lines at every 5 units until it gets to 220. I want the bins to start and end on the grid lines and also show somewhere on the graph the number or count that is represented in each bin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help/ info you can provide about this would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Mar 2013 17:01:28 GMT</pubDate>
    <dc:creator>cloudforest</dc:creator>
    <dc:date>2013-03-15T17:01:28Z</dc:date>
    <item>
      <title>how to set bin boundaries and display count in sgplot histogram</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-bin-boundaries-and-display-count-in-sgplot-histogram/m-p/78542#M2925</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a distribution histogram that has bins that start on the grid lines (as opposed to the default where the grid lines are the midpoint of each bin). Is there a way to do this with the options?&amp;nbsp; Also, is there a way to have the histogram display the count for each individual bin? This is the code I have written so far:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data = dataset noautolegend;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; histogram variable /&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; binstart = 60 binwidth = 5 scale =count;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; refline = 140 / &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; axis = xlineattrs = (color = red thickness =2);&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xaxis label = 'abc' grid values = (60 to 220 by 5);&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The final product I am hoping for is a histogram that has an x axis that starts at 60 and has grid lines at every 5 units until it gets to 220. I want the bins to start and end on the grid lines and also show somewhere on the graph the number or count that is represented in each bin.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help/ info you can provide about this would be much appreciated!&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 17:01:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-bin-boundaries-and-display-count-in-sgplot-histogram/m-p/78542#M2925</guid>
      <dc:creator>cloudforest</dc:creator>
      <dc:date>2013-03-15T17:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: how to set bin boundaries and display count in sgplot histogram</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/how-to-set-bin-boundaries-and-display-count-in-sgplot-histogram/m-p/78543#M2926</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can use the BINSTART= and BINWIDTH= options to control the bin anchor and width. Be sure to use SCALE=COUNT.&amp;nbsp;&amp;nbsp; Use XAXIS VALUES=(60 to 220 by 5) to get the tick marks to agree.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Unfortunately, labeling the bar heights is not a built-in option for the HISTOGRAM statement.&amp;nbsp; I know of three options that you can choose from:&lt;/P&gt;&lt;P&gt;1) Use YAXIS GRID to add horizontal grid lines to the graph. That will make it easy to read the heights of the bars. This is what I would do, since grid lines are less distracting than bar labels.&lt;/P&gt;&lt;P&gt;2) Give up on PROC SGPLOT and use the Graph Template Language (GTL) instead. This enables you to overlay the data labels for the bars on top of the histogram.&lt;/P&gt;&lt;P&gt;3) Create the historgram by using PROC UNIVARIATE instead. See the example at &lt;A href="http://blogs.sas.com/content/iml/2013/03/11/construct-normal-data-from-summary/" title="http://blogs.sas.com/content/iml/2013/03/11/construct-normal-data-from-summary/"&gt; Construct normal data from summary statistics - The DO Loop&lt;/A&gt;&amp;nbsp;&amp;nbsp; For your example, the UNIVARIATE code (on my data) would be&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc univariate data=WalkTimes;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; freq Freq;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; var t;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; histogram t /endpoints=(12 to 24) vscale=count barlabel=count;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 17:40:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/how-to-set-bin-boundaries-and-display-count-in-sgplot-histogram/m-p/78543#M2926</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-03-15T17:40:20Z</dc:date>
    </item>
  </channel>
</rss>

