<?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 Re: Proc univariate - selecting numbers for bins in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975578#M48924</link>
    <description>&lt;P&gt;What do you mean by "table"?&lt;/P&gt;
&lt;P&gt;Sounds like you want to use ODS OUTPUT to convert this TABLE (tabular report) in the output of PROC UNIVARIABLE&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1758636354002.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/110108i05B13E770781B50B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1758636354002.png" alt="Tom_0-1758636354002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;into a DATASET?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;And what is your question or your goal?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Do you want to know if there is a way to change PROC UNIVARIATE so that it produces a different number of bins?&lt;/P&gt;
&lt;P&gt;Do you want to understand how PROC UNIVARIATE decides how many bins are required?&lt;/P&gt;</description>
    <pubDate>Tue, 23 Sep 2025 14:08:49 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2025-09-23T14:08:49Z</dc:date>
    <item>
      <title>Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975561#M48921</link>
      <description>Hi,&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;I need your help.&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;I want to understand how PROC UNIVARIATE decides how many bins are required?&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;I have the following code:&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;ods output HistogramBins = prefix_th;&amp;amp;nbsp;&lt;BR /&gt;proc univariate data = datain noprint;&amp;amp;nbsp;&lt;BR /&gt;histogram y / vscale = percent&amp;amp;nbsp;&amp;amp;nbsp;MIDPERCENTS;&lt;BR /&gt;run;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;and I see depending on the data I have different numbers of bins.&amp;amp;nbsp;&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;I found the original paper:&amp;amp;nbsp;&lt;A href="https://www.jstor.org/stable/2288074&amp;amp;nbsp;and" target="_blank"&gt;https://www.jstor.org/stable/2288074&amp;amp;nbsp;and&lt;/A&gt; I use the following approach:&lt;BR /&gt;width = 3.5 * σ * n^(-1/3)&lt;BR /&gt;nbins = ceil( (max - min) / width )&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;but still I have different number of bins.&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;Can you help?&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;from support:&lt;BR /&gt;&amp;amp;nbsp;&lt;BR /&gt;ENDPOINTS &amp;amp;lt;=values |KEY |UNIFORM&amp;amp;gt;&lt;BR /&gt;uses histogram bin endpoints as the tick mark values for the horizontal axis and determines how to compute the bin width of the histogram bars. You can specify the following values:&lt;BR /&gt;values specifies both the left and right endpoints of each histogram interval. The width of the histogram bars is the difference between consecutive endpoints. The procedure uses the same values for all variables.&lt;BR /&gt;&lt;BR /&gt;KEY&lt;BR /&gt;determines the endpoints for the data in the key cell. The initial number of endpoints is based on the number of observations in the key cell by using the method of Terrell and Scott (1985). The procedure extends the endpoint list for the key cell in either direction as necessary until it spans the data in the remaining cells.&lt;BR /&gt;UNIFORM&lt;BR /&gt;determines the endpoints by using all the observations as if there were no cells. In other words, the number of endpoints is based on the total sample size by using the method of Terrell and Scott (1985).</description>
      <pubDate>Tue, 23 Sep 2025 14:59:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975561#M48921</guid>
      <dc:creator>michal_1407</dc:creator>
      <dc:date>2025-09-23T14:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975567#M48922</link>
      <description>&lt;P&gt;If you just want a HISTOGRAM why are you running PROC UNIVARIATE instead of the appropriate graphics procedure, like PROC SGPLOT with the HISTOGRAM statement?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 13:17:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975567#M48922</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-23T13:17:21Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975576#M48923</link>
      <description>My goal is to get the HistogramBins table.&lt;BR /&gt;Based on this table the histogram is generated. I edited my post, sorry for my mistake</description>
      <pubDate>Tue, 23 Sep 2025 13:57:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975576#M48923</guid>
      <dc:creator>michal_1407</dc:creator>
      <dc:date>2025-09-23T13:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975578#M48924</link>
      <description>&lt;P&gt;What do you mean by "table"?&lt;/P&gt;
&lt;P&gt;Sounds like you want to use ODS OUTPUT to convert this TABLE (tabular report) in the output of PROC UNIVARIABLE&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1758636354002.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/110108i05B13E770781B50B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1758636354002.png" alt="Tom_0-1758636354002.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;into a DATASET?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;And what is your question or your goal?&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Do you want to know if there is a way to change PROC UNIVARIATE so that it produces a different number of bins?&lt;/P&gt;
&lt;P&gt;Do you want to understand how PROC UNIVARIATE decides how many bins are required?&lt;/P&gt;</description>
      <pubDate>Tue, 23 Sep 2025 14:08:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975578#M48924</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-23T14:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975584#M48925</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I want to understand how PROC UNIVARIATE decides how many bins are required.&lt;BR /&gt;&lt;BR /&gt;Only this</description>
      <pubDate>Tue, 23 Sep 2025 14:58:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975584#M48925</guid>
      <dc:creator>michal_1407</dc:creator>
      <dc:date>2025-09-23T14:58:06Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975623#M48935</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327800"&gt;@michal_1407&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Hi,&lt;BR /&gt;&lt;BR /&gt;I want to understand how PROC UNIVARIATE decides how many bins are required.&lt;BR /&gt;&lt;BR /&gt;Only this&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Univariate has been around for a very long time, the first time I used is was 1987 and it wasn't new then, so there are&amp;nbsp;&lt;STRONG&gt;very&amp;nbsp;&lt;/STRONG&gt;many options available to interact.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you check the online references you will likely see repeated references to&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV id="procstat.univariate.histogramstmt" class="aa-section"&gt;
&lt;DIV id="procstat.univariate.histoptdict" class="aa-section"&gt;
&lt;DIV class="aa-options"&gt;
&lt;DL class="aa-options"&gt;
&lt;DD&gt;
&lt;P&gt;the procedure computes the midpoints by using an algorithm (Terrell and Scott &lt;A href="http://127.0.0.1:63872/help/procstat.hlp/procstat_univariate_references.htm#procstat_univariateterr_g85" target="_blank"&gt;1985&lt;/A&gt;)&lt;/P&gt;
&lt;/DD&gt;
&lt;/DL&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;which in the references listed becomes:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xis-refProc"&gt;
&lt;DIV id="procstat_univariate023660" class=" aa-bibliography"&gt;
&lt;DIV&gt;
&lt;UL type="disc"&gt;
&lt;LI id="procstat_univariateterr_g85" class=" aa-bibitem"&gt;
&lt;P&gt;Terrell, G.&amp;nbsp;R., and Scott, D.&amp;nbsp;W. (1985). “Oversmoothed Nonparametric Density Estimates.” &lt;SPAN&gt;&lt;EM&gt;Journal of the American Statistical Association&lt;/EM&gt;&lt;/SPAN&gt; 80:209–214.&lt;/P&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 24 Sep 2025 05:18:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975623#M48935</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-09-24T05:18:45Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975631#M48936</link>
      <description>&lt;P&gt;If you want to get&amp;nbsp;&lt;SPAN&gt;the HistogramBins table ,try the option outhistogram= :&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;proc univariate data=sashelp.heart;
var weight;
histogram weight/&lt;STRONG&gt;outhistogram=&lt;/STRONG&gt; histogram;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;And&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp; might give you a hand.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://blogs.sas.com/content/iml/2023/05/01/overlay-curve-histogram-sas.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2023/05/01/overlay-curve-histogram-sas.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 07:49:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975631#M48936</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-24T07:49:40Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975633#M48937</link>
      <description>Thanks for answer, but I want to understand how sas determines the numbers of BINs</description>
      <pubDate>Wed, 24 Sep 2025 08:20:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975633#M48937</guid>
      <dc:creator>michal_1407</dc:creator>
      <dc:date>2025-09-24T08:20:43Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975634#M48938</link>
      <description>Thanks, I saw this paper, but still I have different number of bins in SAS than in paper and I want to understand how SAS do it.</description>
      <pubDate>Wed, 24 Sep 2025 08:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975634#M48938</guid>
      <dc:creator>michal_1407</dc:creator>
      <dc:date>2025-09-24T08:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975657#M48939</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/327800"&gt;@michal_1407&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thanks, I saw this paper, but still I have different number of bins in SAS than in paper and I want to understand how SAS do it.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't have access to the paper.&amp;nbsp; Can you show your work?&amp;nbsp; How did you pick the KEY cell? (or for that matter how does PROC UNIVARIATE pick the KEY cell?)&amp;nbsp; Or id you ask it to just use UNIFORM bins?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It looks like PROC UNIVARIATE can output a number of statistics that from their names might be related to that paper.&amp;nbsp; Perhaps you could see if using those in the formula shows how it determined the number of bins.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also note that the particular ODS output table you selected does not include empty bins, at least it did not include empty bins at front or back in the examples I tried.&amp;nbsp; Is that confusing your calculations?&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 13:31:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975657#M48939</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-09-24T13:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975667#M48940</link>
      <description>&lt;P&gt;The histogram bin widths (and therefore the number of bins) are not only determined by n, the number of nonmissing values, but also by choosing bin widths that are "convenient", as described in &lt;SPAN&gt;Lewart (&lt;/SPAN&gt;&lt;A href="https://dl.acm.org/doi/pdf/10.1145/362375.362417" target="_blank"&gt;Algorithm 463 of the Collected Algorithms of the ACM&lt;/A&gt;&lt;SPAN&gt;, 1973). You can get the bin locations from Lewart's algorithm by using the GSCALE subroutine in SAS IML.&amp;nbsp; For detail, examples, and a discussion, see&amp;nbsp;&lt;A href="https://blogs.sas.com/content/iml/2024/09/09/location-ticks-graphics.html" target="_blank"&gt;The location of ticks in statistical graphics - The DO Loop&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Sep 2025 15:10:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975667#M48940</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-09-24T15:10:16Z</dc:date>
    </item>
    <item>
      <title>Re: Proc univariate - selecting numbers for bins</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975948#M48953</link>
      <description>&lt;P&gt;If your question is answered, please close this thread. If you have additional questions, please let us know how we can help.&lt;/P&gt;</description>
      <pubDate>Mon, 29 Sep 2025 14:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Proc-univariate-selecting-numbers-for-bins/m-p/975948#M48953</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2025-09-29T14:52:49Z</dc:date>
    </item>
  </channel>
</rss>

