<?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: 100% Stacked and Grouped Bar Chart in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197990#M7383</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 10 Mar 2015 19:24:23 GMT</pubDate>
    <dc:creator>ammarhm</dc:creator>
    <dc:date>2015-03-10T19:24:23Z</dc:date>
    <item>
      <title>100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197984#M7377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am trying to built a stacked bar chart that shows the frequency percentage of a variable, stacked to 100% and further grouped in categories&lt;/P&gt;&lt;P&gt;This example might explain what I am trying to do&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A class="active_link" href="http://www.cdc.gov/nchs/data/databriefs/db182_fig1.png" title="http://www.cdc.gov/nchs/data/databriefs/db182_fig1.png"&gt;http://www.cdc.gov/nchs/data/databriefs/db182_fig1.png&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So there are three levels&lt;/P&gt;&lt;P&gt;Year x (population, discharge, days of care )&lt;/P&gt;&lt;P&gt;And each bar shows age categories stacked to 100%&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can arrange the bars as a stack or group, but cant use both in the same chart&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any suggestions please?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 03:29:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197984#M7377</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-03-10T03:29:15Z</dc:date>
    </item>
    <item>
      <title>Re: 100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197985#M7378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please move to SAS Graphs &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 03:52:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197985#M7378</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-03-10T03:52:05Z</dc:date>
    </item>
    <item>
      <title>Re: 100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197986#M7379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Please show the code that "doesn't work" and what is not appearing that you want. It would help to also provide at least a snippet of your data as data structure may require a different approach in the graphic procedure or modifications to the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Proc Gchart with group and subgroup are possibly one way.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 05:23:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197986#M7379</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2015-03-10T05:23:52Z</dc:date>
    </item>
    <item>
      <title>Re: 100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197987#M7380</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;With SAS 9.4:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgpanel data=sashelp.cars(where=(drivetrain in ('All', 'Front'))) pctlevel=group;&lt;/P&gt;&lt;P&gt;&amp;nbsp; panelby drivetrain / columns=1;&lt;/P&gt;&lt;P&gt;&amp;nbsp; hbar origin / group=type stat=pct;&lt;/P&gt;&lt;P&gt;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SGPanel_G100.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9519_SGPanel_G100.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 05:37:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197987#M7380</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2015-03-10T05:37:27Z</dc:date>
    </item>
    <item>
      <title>Re: 100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197988#M7381</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Great, this is almost exactly what I am looking for&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;If may ask for a further help here, I tried to tweak your code but couldn't achieve what I want&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I am attaching a sample of the dataset in the original post now, also available through this link:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;A href="https://www.dropbox.com/s/viwrxsczu4k3jc3/sample.sas7bdat?dl=0" title="https://www.dropbox.com/s/viwrxsczu4k3jc3/sample.sas7bdat?dl=0"&gt;Dropbox - sample.sas7bdat&lt;/A&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;I have also created an image to explain what I am trying to do:&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;A href="https://www.dropbox.com/s/ho0mbl75pkb9hqy/Layout.png?dl=0" title="https://www.dropbox.com/s/ho0mbl75pkb9hqy/Layout.png?dl=0"&gt;Dropbox - Layout.png&lt;/A&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;and if it can further be stratified by drug (2 panels) it would even be better&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Really appreciate your help.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 08:28:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197988#M7381</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-03-10T08:28:08Z</dc:date>
    </item>
    <item>
      <title>Re: 100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197989#M7382</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think it may be easier to first use Proc Frequency to calculate the percentages for the groups you are interesting, and then plot the graph. The code below plots the percentages of the outcomes for each location, but you will need to modify it so that it can be further stratified by drug. I think all you need to do extra is calculate the percentages by the drug stratification, and then modify Sanjay's code with some of the methods shown below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="SGPlot7.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/9521_SGPlot7.png" width="450" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc format;&lt;BR /&gt;&amp;nbsp; invalue $outcome&lt;BR /&gt;&amp;nbsp;&amp;nbsp; "Yes" = 1&lt;BR /&gt; "No"&amp;nbsp; = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp; value outcome&lt;BR /&gt;&amp;nbsp;&amp;nbsp; 0 = "Yes"&lt;BR /&gt; 1 = "No"&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; other = "";&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data sample;&lt;BR /&gt;&amp;nbsp; set data.sample;&lt;BR /&gt;&amp;nbsp; outcome1n = input(input(outcome1, $outcome.),best.);&lt;BR /&gt;&amp;nbsp; outcome2n = input(input(outcome2, $outcome.),best.);&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sort data = sample;&lt;BR /&gt;&amp;nbsp; by location;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/* Obtaining Percentages for Outcome 1 by location */&lt;BR /&gt;proc freq data = sample;&lt;BR /&gt;&amp;nbsp; by location;&lt;BR /&gt;&amp;nbsp; tables outcome1n / out = freq_summ_1n;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Obtaining Percentages for Outcome 2 by location*/&lt;BR /&gt;proc freq data = sample;&lt;BR /&gt;&amp;nbsp; by location;&lt;BR /&gt;&amp;nbsp; tables outcome2n / out = freq_summ_2n;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Merging Percentages */&lt;BR /&gt;proc sql;&lt;BR /&gt;&amp;nbsp; create table final_data as&lt;BR /&gt;&amp;nbsp; select a.location, coalesce(a.outcome1n, b.outcome2n) as outcome, a.outcome1n as a_outcome, b.outcome2n as b_outcome, a.percent as a_pct, b.percent as b_pct &lt;BR /&gt;&amp;nbsp; from Freq_summ_1n as a full join Freq_summ_2n as b&lt;BR /&gt;&amp;nbsp; on a.location = b.location and a.outcome1n = b.outcome2n;&lt;BR /&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;/* Plotting the data */&lt;/P&gt;&lt;P&gt;proc sgplot data = final_data;&lt;BR /&gt;&amp;nbsp; vbar location / response = a_pct group = outcome discreteoffset = -0.2 groupdisplay = stack barwidth = 0.2 name = "leg1"; /* Outcome 1 */&lt;BR /&gt;&amp;nbsp; vbar location / response = b_pct group = outcome discreteoffset = 0.2 groupdisplay = stack barwidth = 0.2 name = "leg2"; /* Outcome 2 */&lt;BR /&gt;&amp;nbsp; keylegend "leg1" "leg2";&lt;BR /&gt;&amp;nbsp; format outcome outcome.;&lt;BR /&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 13:51:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197989#M7382</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2015-03-10T13:51:58Z</dc:date>
    </item>
    <item>
      <title>Re: 100% Stacked and Grouped Bar Chart</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197990#M7383</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 10 Mar 2015 19:24:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/100-Stacked-and-Grouped-Bar-Chart/m-p/197990#M7383</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2015-03-10T19:24:23Z</dc:date>
    </item>
  </channel>
</rss>

