<?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: Rounding a number before calculating percentages in Proc Tabulate in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/325799#M62274</link>
    <description>&lt;P&gt;Thanks, I was looking for a way to do it right within PROC TABULATE but this will work. I appreciate the help.&lt;/P&gt;</description>
    <pubDate>Wed, 18 Jan 2017 20:13:42 GMT</pubDate>
    <dc:creator>sgnolek</dc:creator>
    <dc:date>2017-01-18T20:13:42Z</dc:date>
    <item>
      <title>Rounding a number before calculating percentages in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/324643#M62194</link>
      <description>&lt;P&gt;I am using proc tabulate to create summary tables. One of the variables I am summing&amp;nbsp;is not a whole number (ex: 0.25). Let's call it "X". I am summing up&amp;nbsp;"X" into different groups&amp;nbsp;(rows), then dividing by the total of "X" across all rows to get a percent &amp;nbsp; - using reppctsum. In the table, all the calculations are being done properly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However! The client thinks of the sum of "X" as a whole number, even though it comes from "bits and pieces" of all of the underlying X values. For example, imagine you are predicting the likelihood of someone coming into your store, and each person has a probability of coming in, the total number of people&amp;nbsp;predicted to come to the store would be the sum of all of those probabilities - &amp;nbsp;but if that sum was 20.5 the client (and I) would predict that 20 people would arrive (not 20 people, and half of another person!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So.... I want proc tabulate to &lt;STRONG&gt;&lt;FONT color="#800080"&gt;show percentages based on the rounded values (not formatted, but actually rounded to the nearest whole number)&lt;/FONT&gt;&lt;/STRONG&gt;. In the table output I have formatted the "X" values to be whole numbers, so they look correct, but the underlying percentage that is calculated is usually just a little bit off because it is not using a&amp;nbsp;rounded value, but the actual value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I can't round to whole numbers before I do the summation because it is the sum of &amp;nbsp;"bits and pieces" of each person that gives me the total prediction I need.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#800080"&gt;Is there any way to force the percentage that is calculated (in this case using reppctsum) to be based on a rounded sum?&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example of the values I have for each group, what percentage I get, and what I would like.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Group A: &amp;nbsp; &amp;nbsp; &amp;nbsp; 12 (actually 11.97, formatted as&amp;nbsp;12) &amp;nbsp; &amp;nbsp; &amp;nbsp;Percent shown: 5.3% (11.97/225.42) &amp;nbsp;Percent desired: 12/225 = 5.3%&lt;/P&gt;
&lt;P&gt;Group B: &amp;nbsp; &amp;nbsp; &amp;nbsp; 20 (actually 20.42, formatted as&amp;nbsp;20) &amp;nbsp; &amp;nbsp; &amp;nbsp;Percent shown: &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;9.1%&lt;/STRONG&gt;&lt;/FONT&gt; (20.42/225.42) &amp;nbsp;Percent desired: 20/225 = &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;8.9%&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Group C: &amp;nbsp; &amp;nbsp; &amp;nbsp; 35 (actually 35.35, formatted as&amp;nbsp;35) &amp;nbsp; &amp;nbsp; &amp;nbsp;Percent shown: &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;15.7%&lt;/FONT&gt;&lt;/STRONG&gt; (35.35/225.42) Percent desired: 35/225 =&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt; 15.6%&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Group &lt;span class="lia-unicode-emoji" title=":anguished_face:"&gt;😧&lt;/span&gt; &amp;nbsp; &amp;nbsp; &amp;nbsp; 41 (actually 40.77, formatted as&amp;nbsp;41)&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Percent shown: &lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;18.1%&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt; (40.77/225.42) Percent desired: 41/225 =&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt; 18.2%&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Group E: &amp;nbsp; &amp;nbsp; &amp;nbsp; 61 (actually 60.91, formatted as 61)&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;Percent shown: &lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;27.0&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;%&lt;/FONT&gt;&lt;/STRONG&gt;&lt;SPAN&gt; (60.91/225.42) Percent desired: 61/225 =&lt;/SPAN&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;&amp;nbsp;27.1%&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;Group F: &amp;nbsp; &amp;nbsp; &amp;nbsp; 56&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Total: &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 225 (actually 225.42 formatted to the whole number, 225)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The table statement I am using to get these values includes:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; pcomex='% of Total'*f=5.*reppctsum&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;where pcomex is the probability of a person "coming to the store"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;THANKS for any help that you can provide! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:36:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/324643#M62194</guid>
      <dc:creator>sgnolek</dc:creator>
      <dc:date>2017-01-13T17:36:00Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a number before calculating percentages in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/324650#M62196</link>
      <description>&lt;P&gt;Before proc tabulate do the sum with Proc means or summary using your group variable(s) as class variables.&lt;/P&gt;
&lt;P&gt;Then round in a data step.&lt;/P&gt;
&lt;P&gt;Then display with proc tabulate.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Jan 2017 17:54:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/324650#M62196</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-01-13T17:54:24Z</dc:date>
    </item>
    <item>
      <title>Re: Rounding a number before calculating percentages in Proc Tabulate</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/325799#M62274</link>
      <description>&lt;P&gt;Thanks, I was looking for a way to do it right within PROC TABULATE but this will work. I appreciate the help.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Jan 2017 20:13:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Rounding-a-number-before-calculating-percentages-in-Proc/m-p/325799#M62274</guid>
      <dc:creator>sgnolek</dc:creator>
      <dc:date>2017-01-18T20:13:42Z</dc:date>
    </item>
  </channel>
</rss>

