<?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: Making a grouped bar chart with both count and percent in datalabel but yaxis only represents co in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521675#M141559</link>
    <description>&lt;P&gt;Come to think of it, it was not that complicated. This code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bar; 
infile datalines dlm=',';
input letter $ group1 group2 group3; 
datalines; 
A,3,2,2
B,2,3,1
C,0,1,0
; 
run;

proc transpose data=bar out=barlong(rename=(_NAME_=Group COL1=value));
   by letter;
run;

proc sql;
   create table GraphData as
   select *,
          cats(value, "(", put(value/(sum(value)), percent.), ")") as datalabel
   from barlong
   group by Group;
quit;

proc sgplot data=GraphData noautolegend noborder;
   vbar Group / response=value group=letter groupdisplay=cluster datalabel=datalabel;
   keylegend / position=e title="" noborder;
   yaxis grid display=(nolabel);
   xaxis display=(nolabel);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gives you this&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="SGPlot16.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25715i4B5E44B2A8A20463/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot16.png" alt="SGPlot16.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 15 Dec 2018 09:37:21 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-12-15T09:37:21Z</dc:date>
    <item>
      <title>Making a grouped bar chart with both count and percent in datalabel but yaxis only represents count</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521667#M141556</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am looking to make a bar chart that is grouped. The tricky part is that I want the datalabels to have both the count and the percent. Below is a picture of what I am looking to make (I used excel to make this). Below that&amp;nbsp;is the code for example data I would like to use to make the attached bar chart.&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: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25713i041301EFC7FE38CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;FONT face="Courier New" size="3"&gt;&lt;CODE class=" language-sas"&gt;data bar;
infile datalines delimiter=",";
input letter $ group1 group2 group3;
datalines;
A, 3, 2, 2
B, 2, 3, 1
C, 0, 1, 0
;
run;&lt;/CODE&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 21:52:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521667#M141556</guid>
      <dc:creator>arielcslin</dc:creator>
      <dc:date>2018-12-14T21:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: Making a grouped bar chart with both count and percent in datalabel but yaxis only represents co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521670#M141557</link>
      <description>&lt;P&gt;You can draw the bar chart doing something like below. About having counts and percentages as datalabels, it can be done, but not directly in PROC SGPLOT I believe. Are you still interested?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bar; 
infile datalines dlm=',';
input letter $ group1 group2 group3; 
datalines; 
A,3,2,2
B,2,3,1
C,0,1,0
; 
run;

proc transpose data=bar out=barlong(rename=(_NAME_=Group COL1=value));
   by letter;
run;

proc sgplot data=barlong noautolegend noborder;
   vbar Group / response=value group=letter groupdisplay=cluster datalabel;
   keylegend / position=e title="" noborder;
   yaxis grid display=(nolabel);
   xaxis display=(nolabel);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 22:14:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521670#M141557</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-14T22:14:53Z</dc:date>
    </item>
    <item>
      <title>Re: Making a grouped bar chart with both count and percent in datalabel but yaxis only represents co</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521675#M141559</link>
      <description>&lt;P&gt;Come to think of it, it was not that complicated. This code&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data bar; 
infile datalines dlm=',';
input letter $ group1 group2 group3; 
datalines; 
A,3,2,2
B,2,3,1
C,0,1,0
; 
run;

proc transpose data=bar out=barlong(rename=(_NAME_=Group COL1=value));
   by letter;
run;

proc sql;
   create table GraphData as
   select *,
          cats(value, "(", put(value/(sum(value)), percent.), ")") as datalabel
   from barlong
   group by Group;
quit;

proc sgplot data=GraphData noautolegend noborder;
   vbar Group / response=value group=letter groupdisplay=cluster datalabel=datalabel;
   keylegend / position=e title="" noborder;
   yaxis grid display=(nolabel);
   xaxis display=(nolabel);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Gives you this&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="SGPlot16.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/25715i4B5E44B2A8A20463/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot16.png" alt="SGPlot16.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 09:37:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Making-a-grouped-bar-chart-with-both-count-and-percent-in/m-p/521675#M141559</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-12-15T09:37:21Z</dc:date>
    </item>
  </channel>
</rss>

