<?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: Inaccuracy of vbar g100 percentage calculations in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63147#M2148</link>
    <description>This is perfect!!  Thanks again!!!!</description>
    <pubDate>Thu, 12 May 2011 15:07:49 GMT</pubDate>
    <dc:creator>ccc143</dc:creator>
    <dc:date>2011-05-12T15:07:49Z</dc:date>
    <item>
      <title>Inaccuracy of vbar g100 percentage calculations</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63143#M2144</link>
      <description>When I run the following, I get 37.96% for dog under year 1 and 34.57% for dog under year 2.&lt;BR /&gt;
&lt;BR /&gt;
With the data given, it should be 287.1/(469.9+287.1) = 37.926% for dog under year 1 and 261.6/(494.3+287.1) = 34.61% for dog under year 2.&lt;BR /&gt;
&lt;BR /&gt;
Am I missing something in the code?  Why aren't the percentages coming out right?  Please see attached.&lt;BR /&gt;
&lt;BR /&gt;
Thanks!&lt;BR /&gt;
&lt;BR /&gt;
data test1;&lt;BR /&gt;
input year cat $3. num;&lt;BR /&gt;
datalines;&lt;BR /&gt;
1 cat 469.9 &lt;BR /&gt;
1 dog 287.1&lt;BR /&gt;
2 cat 494.3 &lt;BR /&gt;
2 dog 261.6&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
goptions reset=all;&lt;BR /&gt;
&lt;BR /&gt;
proc gchart data=test1;&lt;BR /&gt;
vbar year / discrete subgroup=cat&lt;BR /&gt;
group=year g100 nozero&lt;BR /&gt;
freq=num type=percent&lt;BR /&gt;
inside=percent width=20;&lt;BR /&gt;
run;&lt;BR /&gt;
quit;</description>
      <pubDate>Fri, 06 May 2011 15:19:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63143#M2144</guid>
      <dc:creator>ccc143</dc:creator>
      <dc:date>2011-05-06T15:19:15Z</dc:date>
    </item>
    <item>
      <title>Re: Inaccuracy of vbar g100 percentage calculations</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63144#M2145</link>
      <description>I think you'll find that the FREQ option truncates fractional values. Re-run your example without the decimal parts of NUM and you'll get the same result.&lt;BR /&gt;
&lt;BR /&gt;
This calculates the correct percentages but you'll probably not be happy with the vertical axis.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
I find most of the times when I want to use weighted statistics that I have to pre-summarize the data prior to display.&lt;BR /&gt;
&lt;BR /&gt;
proc gchart data=test1;&lt;BR /&gt;
  vbar year / discrete subgroup=cat&lt;BR /&gt;
  sumvar=num&lt;BR /&gt;
  raxis=none&lt;BR /&gt;
  inside=subpct width=20;&lt;BR /&gt;
run;&lt;BR /&gt;
quit; &lt;BR /&gt;
    &lt;BR /&gt;
Message was edited by: ballardw

Message was edited by: ballardw</description>
      <pubDate>Fri, 06 May 2011 21:18:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63144#M2145</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-05-06T21:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Inaccuracy of vbar g100 percentage calculations</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63145#M2146</link>
      <description>Thanks ballardw!  Is there a way to maintain the y-axis in percentages though?</description>
      <pubDate>Mon, 09 May 2011 15:11:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63145#M2146</guid>
      <dc:creator>ccc143</dc:creator>
      <dc:date>2011-05-09T15:11:00Z</dc:date>
    </item>
    <item>
      <title>Re: Inaccuracy of vbar g100 percentage calculations</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63146#M2147</link>
      <description>The approach I would to get data and axis to agree is to pre-process the data as such.&lt;BR /&gt;
&lt;BR /&gt;
proc freq data=test1 noprint;&lt;BR /&gt;
   table year*cat/ outpct out=test2;&lt;BR /&gt;
   weight num;&lt;BR /&gt;
run;&lt;BR /&gt;
   &lt;BR /&gt;
The order of the table variable determines if you want to display row or column percent. The default labels will be ugly as well so provide your own.&lt;BR /&gt;
&lt;BR /&gt;
proc gchart data=test2;&lt;BR /&gt;
   vbar year / discrete subgroup=cat&lt;BR /&gt;
   sumvar=pct_row&lt;BR /&gt;
   inside=subpct width=20;&lt;BR /&gt;
   label pct_row ='%';&lt;BR /&gt;
run;&lt;BR /&gt;
quit;</description>
      <pubDate>Mon, 09 May 2011 23:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63146#M2147</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2011-05-09T23:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: Inaccuracy of vbar g100 percentage calculations</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63147#M2148</link>
      <description>This is perfect!!  Thanks again!!!!</description>
      <pubDate>Thu, 12 May 2011 15:07:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Inaccuracy-of-vbar-g100-percentage-calculations/m-p/63147#M2148</guid>
      <dc:creator>ccc143</dc:creator>
      <dc:date>2011-05-12T15:07:49Z</dc:date>
    </item>
  </channel>
</rss>

