<?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: Number and Percentage by group in PROC REPORT hbar? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626713#M77477</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using SGPLOT, you can just change the option 'data label' to 'seglabel' as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data= sashelp.cars;
	where make in ('Audi' 'BMW');
	hbar make / group= type seglabel stat=percent;
	yaxis fitpolicy= none;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
    <pubDate>Sun, 23 Feb 2020 11:26:10 GMT</pubDate>
    <dc:creator>ed_sas_member</dc:creator>
    <dc:date>2020-02-23T11:26:10Z</dc:date>
    <item>
      <title>Number and Percentage by group in PROC REPORT hbar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626676#M77472</link>
      <description>&lt;P&gt;I have two related questions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;1. Can I report the number of observations by "MAKE" and "TYPE" in the outcome that the below code generates? There are 7 observations for Acura. It seems that a majority of 7 Acuras are Sedan, but I cannot see the exact number.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. Can there be percentages, instead of numbers, presented? It seems to me that there are 1 SUV, 5 Sedan, and 1 Sports in the first car maker group (i.e., Acura). I would like to report the percentages, if possible (i.e., 14%, 72% and 14%).&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;PRE&gt;&lt;CODE class=" language-sas"&gt;
ods graphics/ height= 8in;
proc sgplot data= sashelp.cars;
	hbar make / group= type datalabel ;
	yaxis fitpolicy= none; run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 22 Feb 2020 22:18:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626676#M77472</guid>
      <dc:creator>braam</dc:creator>
      <dc:date>2020-02-22T22:18:53Z</dc:date>
    </item>
    <item>
      <title>Re: Number and Percentage by group in PROC REPORT hbar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626687#M77474</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data= sashelp.cars;
where make in ('Audi' 'BMW');
	hbar make / group= type datalabel stat=freq  groupdisplay=cluster;
	yaxis fitpolicy= none; run;
	
	proc sgplot data= sashelp.cars;
where make in ('Audi' 'BMW');
	hbar make / group= type datalabel stat=pct  groupdisplay=cluster;
	yaxis fitpolicy= none; run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 23 Feb 2020 04:10:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626687#M77474</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2020-02-23T04:10:32Z</dc:date>
    </item>
    <item>
      <title>Re: Number and Percentage by group in PROC REPORT hbar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626704#M77475</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You can also display both frequency and percentage using PROC GCHART:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;axis1 label=none;
proc gchart data= sashelp.cars;
	where make in ('Audi' 'BMW');
	hbar type /group=make subgroup=type freq percent space=0 raxis=axis1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="Capture d’écran 2020-02-23 à 09.41.43.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36328i5BA0CDF620541069/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture d’écran 2020-02-23 à 09.41.43.png" alt="Capture d’écran 2020-02-23 à 09.41.43.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 08:43:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626704#M77475</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-23T08:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: Number and Percentage by group in PROC REPORT hbar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626712#M77476</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/292097"&gt;@ed_sas_member&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for your answers! But isn't there a way to solve this with the style of graph being unchanged?&lt;/P&gt;
&lt;P&gt;I mean, one single bar for one car maker where there are multiple types of cars.&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 11:13:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626712#M77476</guid>
      <dc:creator>braam</dc:creator>
      <dc:date>2020-02-23T11:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Number and Percentage by group in PROC REPORT hbar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626713#M77477</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;using SGPLOT, you can just change the option 'data label' to 'seglabel' as follows:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data= sashelp.cars;
	where make in ('Audi' 'BMW');
	hbar make / group= type seglabel stat=percent;
	yaxis fitpolicy= none;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Best,&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 11:26:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626713#M77477</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-23T11:26:10Z</dc:date>
    </item>
    <item>
      <title>Re: Number and Percentage by group in PROC REPORT hbar?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626725#M77478</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/279507"&gt;@braam&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is another approach, using a file for annotation:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars noprint order=freq;
	table type / out=cars_freq;
	by make;
run;

/* file for annotation */
data bar_anno;
	set cars_freq;
	function='label';
	retain xsys '2' ysys '2' color 'black' when 'a';
	midpoint=make;
	subgroup=type;
	position='+';
	text=strip(put(percent/100, percent8.0));
run;

/* Graph */
axis1 label=(angle=90 "Make");
axis2 label=none;

proc gchart data=sashelp.cars;
	hbar make / subgroup=type nostats space=0 annotate=bar_anno maxis=axis1 raxis=axis2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Unknown.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/36334iD2255983A76570E6/image-size/large?v=v2&amp;amp;px=999" role="button" title="Unknown.png" alt="Unknown.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 23 Feb 2020 14:38:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Number-and-Percentage-by-group-in-PROC-REPORT-hbar/m-p/626725#M77478</guid>
      <dc:creator>ed_sas_member</dc:creator>
      <dc:date>2020-02-23T14:38:26Z</dc:date>
    </item>
  </channel>
</rss>

