<?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 to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572126#M18448</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nope, those percentages don't add to 100 in each group (100% for males and 100% for females).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I exclude some data to exaggerate the differences and make the problem more visible, you can see that the red bars don't add to 100% and the blue bars don't either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
	set sashelp.class;
	if sex='M' and age&amp;lt;14 then delete;
run;
proc sgplot data=class;
    vbar age/group=sex groupdisplay=cluster stat=pct;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you would need to pre-summarize the data to get the percentage of age and sex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.class out=work.summary;
   class age sex;
   table age,
         sex*colpctn
         ;
run;

proc sgplot data=work.summary;
   vbar age/response=pctn_01 group=sex groupdisplay=cluster
   ;
   label pctn_01='Percent';
run;&lt;/PRE&gt;</description>
    <pubDate>Tue, 09 Jul 2019 15:31:50 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2019-07-09T15:31:50Z</dc:date>
    <item>
      <title>How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572064#M18434</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.class;
    histogram age/group=sex transparency=0.8;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;produces this plot&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30858iEE100A94B3775086/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;but I want the blue and red bars grouped instead of overlapped, such as this example found on the Internet:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30857i15DF7448A95EDF00/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I get this from PROC SGPLOT?&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:12:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572064#M18434</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-09T14:12:22Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572081#M18438</link>
      <description>&lt;P&gt;Use a VBAR instead of a HISTOGRAM:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.class;
    vbar age / group=sex groupdisplay=cluster;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Hope this helps!&lt;BR /&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:28:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572081#M18438</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-07-09T14:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572087#M18441</link>
      <description>&lt;P&gt;Sorry,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp;, VBAR doesn't work since it produces percentages that do not add up to 100 in each group, as HISTOGRAM does (and like the G100 option of PROC GCHART). So VBAR does not produce the plot I want.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:38:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572087#M18441</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-09T14:38:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572089#M18443</link>
      <description>&lt;P&gt;Sorry, I did not know you needed that. You just need to add two options to the previous code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.class pctlevel=group;
    vbar age / group=sex groupdisplay=cluster stat=pct;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Thanks!&lt;BR /&gt;Dan&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:48:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572089#M18443</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-07-09T14:48:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572097#M18444</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nope, those percentages don't add to 100 in each group (100% for males and 100% for females).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I exclude some data to exaggerate the differences and make the problem more visible, you can see that the red bars don't add to 100% and the blue bars don't either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
	set sashelp.class;
	if sex='M' and age&amp;lt;14 then delete;
run;
proc sgplot data=class;
    vbar age/group=sex groupdisplay=cluster stat=pct;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 14:56:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572097#M18444</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-09T14:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572125#M18447</link>
      <description>&lt;P&gt;Perhaps you just need to generate the percentages yourself and then plot them?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=class ;
  class sex age ;
  output out=stats ;
run;
data summary;
  merge 
        stats(where=(_type_ in (2)) rename=(_freq_=bign))
        stats(where=(_type_ in (3)) rename=(_freq_=littlen))
  ;
  by sex ;
  percent=littlen/bign;
run;
proc sgplot data=summary;
  vbar age/group=sex groupdisplay=cluster responce=percent stat=sum;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30884i33F1AF487D5AC74F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 15:30:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572125#M18447</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2019-07-09T15:30:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572126#M18448</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nope, those percentages don't add to 100 in each group (100% for males and 100% for females).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If I exclude some data to exaggerate the differences and make the problem more visible, you can see that the red bars don't add to 100% and the blue bars don't either.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
	set sashelp.class;
	if sex='M' and age&amp;lt;14 then delete;
run;
proc sgplot data=class;
    vbar age/group=sex groupdisplay=cluster stat=pct;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Then you would need to pre-summarize the data to get the percentage of age and sex.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc tabulate data=sashelp.class out=work.summary;
   class age sex;
   table age,
         sex*colpctn
         ;
run;

proc sgplot data=work.summary;
   vbar age/response=pctn_01 group=sex groupdisplay=cluster
   ;
   label pctn_01='Percent';
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 09 Jul 2019 15:31:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572126#M18448</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-09T15:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572129#M18449</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, I guessed that was the case, but I was hoping there was some option in SGPLOT I was missing.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 15:35:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572129#M18449</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2019-07-09T15:35:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to get Grouped (not Stacked or overlapped) Histograms from PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572146#M18450</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/159"&gt;@Tom&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks, I guessed that was the case, but I was hoping there was some option in SGPLOT I was missing.&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Going back to GCHART in SAS 6 I was always fighting with the procedure options for percentages and just gave up and always did my summary. At least then when something looked off I knew who to blame...&lt;img id="smileyembarrassed" class="emoticon emoticon-smileyembarrassed" src="https://communities.sas.com/i/smilies/16x16_smiley-embarrassed.png" alt="Smiley Embarassed" title="Smiley Embarassed" /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2019 16:32:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-get-Grouped-not-Stacked-or-overlapped-Histograms-from/m-p/572146#M18450</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-07-09T16:32:32Z</dc:date>
    </item>
  </channel>
</rss>

