<?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 sgplot percentage within each group in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804404#M316763</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am using below code to draw a bar graph. The total percentage of all groups in the graph is 100%. However I want to get 100% for each group. For example, the total of "5.sinif" should be 100%, the total of "6.sinif" should be 100%. pctlevel statement did not resolve my question. The second graph was populated when I used pctlevel=group.&lt;/P&gt;
&lt;P&gt;Also, "sinif" below the x category&amp;nbsp; in the graph is not sorted. How can I sort it?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=ss;
where sinif&amp;lt;9;
vbar _3_Ogretmen_Ogrenci/group=sinif stat=percent datalabel groupdisplay=cluster;
xaxis label= "3.Ogretmen-ogrenci";
yaxis label= "Yuzde";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot61.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69863i45F81161F9302493/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot61.png" alt="SGPlot61.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot64.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69864iA6A6666E6DD7AE27/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot64.png" alt="SGPlot64.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Sun, 27 Mar 2022 15:50:09 GMT</pubDate>
    <dc:creator>dustychair</dc:creator>
    <dc:date>2022-03-27T15:50:09Z</dc:date>
    <item>
      <title>sgplot percentage within each group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804404#M316763</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I am using below code to draw a bar graph. The total percentage of all groups in the graph is 100%. However I want to get 100% for each group. For example, the total of "5.sinif" should be 100%, the total of "6.sinif" should be 100%. pctlevel statement did not resolve my question. The second graph was populated when I used pctlevel=group.&lt;/P&gt;
&lt;P&gt;Also, "sinif" below the x category&amp;nbsp; in the graph is not sorted. How can I sort it?&lt;/P&gt;
&lt;P&gt;Thank you&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=ss;
where sinif&amp;lt;9;
vbar _3_Ogretmen_Ogrenci/group=sinif stat=percent datalabel groupdisplay=cluster;
xaxis label= "3.Ogretmen-ogrenci";
yaxis label= "Yuzde";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot61.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69863i45F81161F9302493/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot61.png" alt="SGPlot61.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot64.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/69864iA6A6666E6DD7AE27/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot64.png" alt="SGPlot64.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 27 Mar 2022 15:50:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804404#M316763</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2022-03-27T15:50:09Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot percentage within each group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804421#M316773</link>
      <description>Hello,&lt;BR /&gt;&lt;BR /&gt;I think you want to add a PCTLEVEL=GROUP option to your SGPLOT statement. The PCTLEVEL= option tells the procedure the level at which the percentages need to add up to 100.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/vdmmlcdc/8.1/grstatproc/p073bl97jzadkmn15lhq58yiy2uh.htm#p0gsg1yxcwryyun1xq0h03c27ewg" target="_blank"&gt;https://documentation.sas.com/doc/en/vdmmlcdc/8.1/grstatproc/p073bl97jzadkmn15lhq58yiy2uh.htm#p0gsg1yxcwryyun1xq0h03c27ewg&lt;/A&gt;</description>
      <pubDate>Sun, 27 Mar 2022 17:57:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804421#M316773</guid>
      <dc:creator>svh</dc:creator>
      <dc:date>2022-03-27T17:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot percentage within each group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804424#M316776</link>
      <description>&lt;P&gt;I like to use PROC FREQ to create the statistics, then use PROC SGPLOT to visualize the bars. For examples and code, see &lt;A href="https://blogs.sas.com/content/iml/2014/04/08/construct-a-stacked-bar-chart-in-sas-where-each-bar-equals-100.html" target="_self"&gt;this article on 100% bar charts&lt;/A&gt;. The article focuses on STACKED bar charts, so the example use GROUPDISPLAY=STACK. However, you want CLUSTERED bar charts, so modify the examples to use&amp;nbsp;GROUPDISPLAY=CLUSTER. For example, here is the modification of the first example in the article:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars(where=(Type^="Hybrid")) out=cars;
by Origin;                     /* sort X categories */
run;
 
proc freq data=cars noprint;
by Origin;                    /* X categories on BY statement */
tables Type / out=FreqOut;    /* Y (stacked groups) on TABLES statement */
run;
 
title "100% Stacked Bar Chart";
proc sgplot data=FreqOut;
vbar Origin / response=Percent group=Type groupdisplay=cluster;
xaxis discreteorder=data;
yaxis grid values=(0 to 100 by 10) label="Percentage of Total with Group";
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 27 Mar 2022 18:39:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804424#M316776</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-03-27T18:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot percentage within each group</title>
      <link>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804560#M316845</link>
      <description>&lt;P&gt;Thank you,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Mar 2022 16:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/sgplot-percentage-within-each-group/m-p/804560#M316845</guid>
      <dc:creator>dustychair</dc:creator>
      <dc:date>2022-03-28T16:30:09Z</dc:date>
    </item>
  </channel>
</rss>

