<?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: Creating percentage by group in bar chart in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643181#M78435</link>
    <description>&lt;P&gt;Thank you very much! This community is great!!!&lt;/P&gt;</description>
    <pubDate>Mon, 27 Apr 2020 03:00:44 GMT</pubDate>
    <dc:creator>Kyra</dc:creator>
    <dc:date>2020-04-27T03:00:44Z</dc:date>
    <item>
      <title>Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643010#M78425</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am creating a bar chart but would like to get percentage rather than frequency.&lt;/P&gt;&lt;P&gt;And percentage i am interested in is not percentage of total frequency but percentage of group frequency.&lt;/P&gt;&lt;P&gt;My SAS code is like below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;ods graphics on;&lt;BR /&gt;proc sgplot data=red.survey2;&lt;BR /&gt;vbar I_feel_well_informed_about_the_C /group=Program__select_one_ groupdisplay=cluster ;&lt;BR /&gt;format I_feel_well_informed_about_the_C $category. ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And results are attached. I am interested in percentage rather than frequency in y axis.&amp;nbsp; I a way for the group agree it sums to 100% , for disagree it sums to 100%.&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;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 12:39:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643010#M78425</guid>
      <dc:creator>Kyra</dc:creator>
      <dc:date>2020-04-26T12:39:59Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643011#M78426</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;vbar I_feel_well_informed_about_the_C /group=Program__select_one_ groupdisplay=cluster stat=percent;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For future reference, many people will not download attachments, and so the output you want to show us should be pasted directly into your message. &lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 12:47:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643011#M78426</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-04-26T12:47:24Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643012#M78427</link>
      <description>&lt;P&gt;If you add&lt;/P&gt;
&lt;P&gt;STAT=percent&lt;/P&gt;
&lt;P&gt;to the VBAR statement, the Y axis will show percentages.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 13:01:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643012#M78427</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-04-26T13:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643035#M78428</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;STAT=percent gives me percentage out of total frequency.&lt;/P&gt;&lt;P&gt;I am interested&amp;nbsp; in getting percentage out of total who agreed, So the sum of 3 bars in agreed should be 100%,&lt;/P&gt;&lt;P&gt;the sum of total who disagreed should be 100% and the sum of neutral should be 100 too.&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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 26 Apr 2020 15:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643035#M78428</guid>
      <dc:creator>Kyra</dc:creator>
      <dc:date>2020-04-26T15:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643121#M78431</link>
      <description>&lt;P&gt;See the article,&amp;nbsp;&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;"Construct a stacked bar chart in SAS where each bar equals 100%".&lt;/A&gt; The article discusses a stacked bar chart, but you can use the same code and change the GROUPDISPLAY= option to CLUSTER&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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, 26 Apr 2020 20:12:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643121#M78431</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-04-26T20:12:02Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643129#M78433</link>
      <description>&lt;P&gt;Thank you very much for reply! I tried the following code;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sort data=red.survey2 out=red.informed;&lt;BR /&gt;by I_feel_well_informed_about_the_C;&lt;BR /&gt;format I_feel_well_informed_about_the_C $category. ;&lt;BR /&gt;run;&lt;BR /&gt;proc freq data=red.informed noprint;&lt;BR /&gt;by I_feel_well_informed_about_the_C;&lt;BR /&gt;tables Program__select_one_ / out=red.FreqOutt;&lt;BR /&gt;format I_feel_well_informed_about_the_C $category. ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sgplot data=red.FreqOutt;&lt;BR /&gt;vbar I_feel_well_informed_about_the_C / response=Percent group=Program__select_one_ groupdisplay=cluster;&lt;BR /&gt;xaxis discreteorder=data;&lt;BR /&gt;yaxis grid values=(0 to 100 by 10) label="Percentage of Total with Group";&lt;BR /&gt;format I_feel_well_informed_about_the_C $category. ;&lt;BR /&gt;run; Following is the output.&lt;/P&gt;&lt;P&gt;&lt;U&gt;However, for the group how is sum more than 100%. I wanted it to be 100% for the 3 bars in agree group. similar for disagree and neutral group.&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the&amp;nbsp; output-&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot3.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/38776i15FE4D86CF2409FB/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot3.png" alt="SGPlot3.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV class="mceNonEditable lia-copypaste-placeholder"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Sun, 26 Apr 2020 20:56:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643129#M78433</guid>
      <dc:creator>Kyra</dc:creator>
      <dc:date>2020-04-26T20:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643163#M78434</link>
      <description>&lt;P&gt;I suspect your PROC FREQ call is incorrect. You want to get the row totals. The output should look like the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
length Informed Program $8; 
input Informed Program Percent;
datalines;
Agree    Anesth  41 
Agree    Emerg   26
Agree    GenSurg 33
Disagree Anesth  39 
Disagree Emerg    8
Disagree GenSurg 53
Neutral  Anesth  34 
Neutral  Emerg   11
Neutral  GenSurg 55
;

proc sgplot data=Have;
vbar Informed / response=Percent group=Program 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>Mon, 27 Apr 2020 00:44:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643163#M78434</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-04-27T00:44:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating percentage by group in bar chart</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643181#M78435</link>
      <description>&lt;P&gt;Thank you very much! This community is great!!!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2020 03:00:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-percentage-by-group-in-bar-chart/m-p/643181#M78435</guid>
      <dc:creator>Kyra</dc:creator>
      <dc:date>2020-04-27T03:00:44Z</dc:date>
    </item>
  </channel>
</rss>

