<?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: sgplot stack bar by descending order while keeping group order inside each bar in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725989#M21139</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Kriss,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your advice. I tried your sorting but unfortunately the issues are still there (the output stays the same).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Alicia&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Mar 2021 21:24:06 GMT</pubDate>
    <dc:creator>garfieldyue</dc:creator>
    <dc:date>2021-03-12T21:24:06Z</dc:date>
    <item>
      <title>sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725978#M21136</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I’m having trouble in the following bar plot.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My goals are:&lt;BR /&gt;- Descending order by the total count of each key word&lt;BR /&gt;- The same order of two teams inside each bar&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="stack bars.png" style="width: 624px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55896i5977B52A73C4DBAE/image-size/large?v=v2&amp;amp;px=999" role="button" title="stack bars.png" alt="stack bars.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;The code I’m using now is as below:&lt;/P&gt;&lt;PRE&gt;proc sort data=rct; &lt;BR /&gt;  by descending totalct team;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;proc sgplot data = rct;  
                                    
  VBAR keyword /RESPONSE = count  /*y-axis: count per keyword per team*/  
                  group = team    /*stack each bar with two teams*/
                  categoryorder = respdesc; /*order by count of each team per keyword, not the total count of each keyword*/
       
run;&lt;/PRE&gt;&lt;P&gt;Part of the data is like below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="data.png" style="width: 610px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55897i56787991B255B487/image-size/large?v=v2&amp;amp;px=999" role="button" title="data.png" alt="data.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know the above code is not 100% correct in terms of achieving my goals, but I don’t know what code (proc or options) to use in this case.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Alicia&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 20:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725978#M21136</guid>
      <dc:creator>garfieldyue</dc:creator>
      <dc:date>2021-03-12T20:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725986#M21137</link>
      <description>&lt;P&gt;Hi Alicia,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your code looks correct. Have you tried to sort your data by descending count totalct team?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Many thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kriss&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 21:08:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725986#M21137</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2021-03-12T21:08:15Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725988#M21138</link>
      <description>&lt;P&gt;read this article.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Graphics-Programming/sgplot-hbar-Is-it-possible-to-sort-categories-by-size-and-groups/td-p/614158" target="_blank"&gt;Solved: sgplot hbar - Is it possible to sort categories by... - SAS Support Communities&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I see that there's an example of a stacked bar plot there that has blue and red in the correct order.&amp;nbsp; Good luck.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 21:21:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725988#M21138</guid>
      <dc:creator>PhilC</dc:creator>
      <dc:date>2021-03-12T21:21:24Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725989#M21139</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;SPAN&gt;Kriss,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks for your advice. I tried your sorting but unfortunately the issues are still there (the output stays the same).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Alicia&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 21:24:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725989#M21139</guid>
      <dc:creator>garfieldyue</dc:creator>
      <dc:date>2021-03-12T21:24:06Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725997#M21141</link>
      <description>&lt;P&gt;Hi Alicia,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay, I see. Try this code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data rct2;&lt;BR /&gt;&amp;nbsp; set rct;&lt;BR /&gt;&amp;nbsp; totalct_y = totalct + 10;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data = rct2; &lt;BR /&gt;&amp;nbsp; vbarparm category=keyword response = count / group = team grouporder = data;&lt;BR /&gt;&amp;nbsp; scatter x = keyword y = totalct_y / markerchar= totalct;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Mar 2021 22:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/725997#M21141</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2021-03-12T22:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/726042#M21142</link>
      <description>&lt;P&gt;This works, Kriss. Wonderful!&lt;/P&gt;&lt;P&gt;I don't quite understand why using "totalct_y = totalct + 10" in your data step. Could you explain a bit?&lt;/P&gt;&lt;P&gt;Thanks so much!&lt;/P&gt;</description>
      <pubDate>Sat, 13 Mar 2021 13:18:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/726042#M21142</guid>
      <dc:creator>garfieldyue</dc:creator>
      <dc:date>2021-03-13T13:18:47Z</dc:date>
    </item>
    <item>
      <title>Re: sgplot stack bar by descending order while keeping group order inside each bar</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/726043#M21143</link>
      <description>&lt;P&gt;Hi PhilC,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for pulling up the previous case - it was exactly what I wanted to do. The only thing is when I was trying to do the complicated sql step (I'm entry level), SAS kept giving errors although I replaced my variables accordingly. I saved the solution for future use. It was absolutely helpful!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Alicia&lt;/P&gt;</description>
      <pubDate>Sat, 13 Mar 2021 13:29:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgplot-stack-bar-by-descending-order-while-keeping-group-order/m-p/726043#M21143</guid>
      <dc:creator>garfieldyue</dc:creator>
      <dc:date>2021-03-13T13:29:49Z</dc:date>
    </item>
  </channel>
</rss>

