<?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: How do I get percents by group in SGPLOT? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485254#M16736</link>
    <description>&lt;P&gt;If I'm interpreting your request correctly, you really want to set PCTLEVEL=GRAPH (which is the default). Give that a try and see if the numbers are what you expect.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
    <pubDate>Wed, 08 Aug 2018 19:29:39 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2018-08-08T19:29:39Z</dc:date>
    <item>
      <title>How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485250#M16734</link>
      <description>&lt;P&gt;I am using this code to get percent of bars within group (data_column_C), but what I am getting is percent within data_column_A category.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically I want the percents to sum up to 100% for data_column_C and have individual bar by data_column_A.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=data_table pctlevel=group;
vline data_column_A /response=data_column_B stat=mean limitstat=clm markers group=data_column_C lineattrs=(thickness=2);
vbar data_column_A / response=data_column_B y2axis transparency=0.75 group=data_column_C groupdisplay=cluster stat=percent;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:03:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485250#M16734</guid>
      <dc:creator>kpro1234</dc:creator>
      <dc:date>2018-08-08T19:03:06Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485254#M16736</link>
      <description>&lt;P&gt;If I'm interpreting your request correctly, you really want to set PCTLEVEL=GRAPH (which is the default). Give that a try and see if the numbers are what you expect.&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:29:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485254#M16736</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2018-08-08T19:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485255#M16737</link>
      <description>I had tried that, when I do PCTLEVEL=GRAPH I get percents for the entire data.&lt;BR /&gt;&lt;BR /&gt;If I do PCTLEVEL=GRAPH and then add a BY DATA_COLUMN_C statement after VBAR, then I get what I need but in two different graphs. But I am trying to have them both in one GRAPH.&lt;BR /&gt;&lt;BR /&gt;Trying to get distribution of data in PERCENT but the percents should add up to 100 by the GROUP variable.</description>
      <pubDate>Wed, 08 Aug 2018 19:33:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485255#M16737</guid>
      <dc:creator>kpro1234</dc:creator>
      <dc:date>2018-08-08T19:33:47Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485260#M16738</link>
      <description>&lt;P&gt;Can you post a picture of what you're getting without the BY statement?&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:38:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485260#M16738</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2018-08-08T19:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485263#M16739</link>
      <description>&lt;P&gt;&amp;nbsp;What I want is that the blue bars sum up to 100% and the pink bars also sum up to 100%. The variable name differentiating them is DATA_COLUMN_C in my code above. 0-14 are DATA_COLUMN_A values and DATA_COLUMN_B is the response variable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 567px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/22337i324EA52959748055/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485263#M16739</guid>
      <dc:creator>kpro1234</dc:creator>
      <dc:date>2018-08-08T19:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485265#M16740</link>
      <description>&lt;P&gt;The way you can do this is to transpose the data such that the values in&amp;nbsp;&lt;SPAN&gt;DATA_COLUMN_B are put into&amp;nbsp;DATA_COLUMN_B1 and&amp;nbsp;DATA_COLUMN_B2, depending on the value in&amp;nbsp;DATA_COLUMN_C. Then, your plot becomes 2 vbar sttements with stat=mean and 2 vline statements with stat=percent. The PCTLEVEL option will not be required.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Hope this helps!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Dan&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 08 Aug 2018 19:54:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485265#M16740</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2018-08-08T19:54:16Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485267#M16741</link>
      <description>In this case I have 2 distinct values in DATA_COLUMN_C, but I more in other scenarios. So transforming and repeating should work as you suggested, but I wish there was an option that would make it happen without transforming data. From the documentation PCTLEVEL seemed like was the solution but it is giving percent by DATA_COLUMN_A grouping. Thanks for your responses, will have to do that work around if no other solution.</description>
      <pubDate>Wed, 08 Aug 2018 20:01:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/485267#M16741</guid>
      <dc:creator>kpro1234</dc:creator>
      <dc:date>2018-08-08T20:01:41Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/649312#M19945</link>
      <description>&lt;P&gt;i think this is a much needed function in sgplot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my work-around is to use proc freq to export the percentages and then use sgplot. like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc freq data=xxx noprint;table a*b/out=XXXX outpct;run;&lt;/P&gt;&lt;P&gt;proc sgplot data=XXXX;vbar b /response=pct_row group=a groupdisplay=cluster;run;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 17:25:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/649312#M19945</guid>
      <dc:creator>yin1</dc:creator>
      <dc:date>2020-05-20T17:25:23Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/767088#M21948</link>
      <description>This exact code worked for me. Thank you.</description>
      <pubDate>Fri, 10 Sep 2021 18:34:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/767088#M21948</guid>
      <dc:creator>rwat1</dc:creator>
      <dc:date>2021-09-10T18:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/777117#M22201</link>
      <description>This is exactly what I'm trying to do! But it looks like proc sgplot doesn't offer any options.</description>
      <pubDate>Thu, 28 Oct 2021 19:53:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/777117#M22201</guid>
      <dc:creator>kz_</dc:creator>
      <dc:date>2021-10-28T19:53:22Z</dc:date>
    </item>
    <item>
      <title>Re: How do I get percents by group in SGPLOT?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/803258#M22688</link>
      <description>&lt;P&gt;These work around codes work for me. Now, I'm having the percentage display on the bars (datalabel). Is it possible to limit the decimal places to one only. It's displaying 3 and that's too much.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 01:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-do-I-get-percents-by-group-in-SGPLOT/m-p/803258#M22688</guid>
      <dc:creator>katslau</dc:creator>
      <dc:date>2022-03-22T01:33:18Z</dc:date>
    </item>
  </channel>
</rss>

