<?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 proc sgplot vbar stacked: axistable always in reverse order: how can I turn? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847013#M334871</link>
    <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;I have a problem with the axistable for a vbar statement in sgplot.&lt;/P&gt;&lt;P&gt;Please try the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test;&lt;/P&gt;&lt;P&gt;INPUT time $&amp;nbsp; result&amp;nbsp; $&amp;nbsp; no @@;&lt;/P&gt;&lt;P&gt;CARDS;&lt;BR /&gt;Begin a 1 Begin a 1 Begin a 1 Begin b 1 Begin b 1&lt;BR /&gt;End a 1 End b 1 End b 1 End b 1 End b 1&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SGPLOT DATA=test;&lt;BR /&gt;VBAR time / GROUP=result GROUPDISPLAY=STACK GROUPORDER= DESCENDING STAT=SUM NOSTATLABEL;&lt;BR /&gt;XAXISTABLE no / STAT=SUM CLASSDISPLAY=STACK CLASSORDER= DESCENDING LOCATION=inside POSITION=BOTTOM;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will see, that the order in the XAXISTABLE stacks is reverse to the order in the graphic-stack itself.&lt;/P&gt;&lt;P&gt;Changing the CLASSORDER-statement does nothing, it is redundant. Changing the GROUPORDER-statement turns both, grafic stack and table stack. So again the order is reverse to each other.&lt;/P&gt;&lt;P&gt;Does anyone have a solution how to bring both in the same order?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(SAS version 9.4 TS Level 1M4 on windows)&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Uli&lt;/P&gt;</description>
    <pubDate>Wed, 30 Nov 2022 10:54:58 GMT</pubDate>
    <dc:creator>USchu</dc:creator>
    <dc:date>2022-11-30T10:54:58Z</dc:date>
    <item>
      <title>proc sgplot vbar stacked: axistable always in reverse order: how can I turn?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847013#M334871</link>
      <description>&lt;P&gt;Hello everybody,&lt;/P&gt;&lt;P&gt;I have a problem with the axistable for a vbar statement in sgplot.&lt;/P&gt;&lt;P&gt;Please try the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA test;&lt;/P&gt;&lt;P&gt;INPUT time $&amp;nbsp; result&amp;nbsp; $&amp;nbsp; no @@;&lt;/P&gt;&lt;P&gt;CARDS;&lt;BR /&gt;Begin a 1 Begin a 1 Begin a 1 Begin b 1 Begin b 1&lt;BR /&gt;End a 1 End b 1 End b 1 End b 1 End b 1&lt;BR /&gt;;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;PROC SGPLOT DATA=test;&lt;BR /&gt;VBAR time / GROUP=result GROUPDISPLAY=STACK GROUPORDER= DESCENDING STAT=SUM NOSTATLABEL;&lt;BR /&gt;XAXISTABLE no / STAT=SUM CLASSDISPLAY=STACK CLASSORDER= DESCENDING LOCATION=inside POSITION=BOTTOM;&lt;BR /&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will see, that the order in the XAXISTABLE stacks is reverse to the order in the graphic-stack itself.&lt;/P&gt;&lt;P&gt;Changing the CLASSORDER-statement does nothing, it is redundant. Changing the GROUPORDER-statement turns both, grafic stack and table stack. So again the order is reverse to each other.&lt;/P&gt;&lt;P&gt;Does anyone have a solution how to bring both in the same order?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;(SAS version 9.4 TS Level 1M4 on windows)&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Uli&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 10:54:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847013#M334871</guid>
      <dc:creator>USchu</dc:creator>
      <dc:date>2022-11-30T10:54:58Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot vbar stacked: axistable always in reverse order: how can I turn?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847032#M334884</link>
      <description>&lt;P&gt;Hallo&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/437393"&gt;@USchu&lt;/a&gt;&amp;nbsp;and welcome to the SAS Support Communities!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Looking at the last post of the 2020 thread&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Graphics-Programming/stacked-barchart-how-to-order-the-legend-and-the-xaxis-table/m-p/646776/highlight/true#M19871" target="_blank" rel="noopener"&gt;stacked barchart - how to order the legend and the xaxis table?&lt;/A&gt; (which was probably the solution, although the original poster didn't mark it as such) it appears that the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n0mc5dtithid5mn13c54dlgaceq3.htm" target="_blank" rel="noopener"&gt;VBARPARM statement&lt;/A&gt; is the key to the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So you would need to presummarize the data&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=test nway;
class time result;
var no;
output out=want sum=;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;and then use something like&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=want;
vbarparm category=time response=no / group=result grouporder=descending;
xaxistable no / class=result location=inside;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Here I use the default of the &lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p1cebnxst19wccn1s44lyk5nk2vx.htm#n0zgdoyqkmw8kpn1akmjhi83600o" target="_blank" rel="noopener"&gt;CLASSORDER= option&lt;/A&gt;, which is DATA, but you could explicitly specify &lt;FONT face="courier new,courier"&gt;classorder=ascending&lt;/FONT&gt;&amp;nbsp;to obtain the same result with input dataset WANT. The important point is that now CLASSORDER= (in the XAXISTABLE statement) and GROUPORDER= (in the VBARPARM statement) can be specified independently of each other, whereas with the VBAR statement the CLASSORDER= option is ignored (see documentation linked above). So the combination of &lt;FONT face="courier new,courier"&gt;grouporder=ascending&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;classorder=descending&lt;/FONT&gt;&amp;nbsp;reverses both orders, maintaining the consistency that you want.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Nov 2022 12:41:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847032#M334884</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2022-11-30T12:41:45Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot vbar stacked: axistable always in reverse order: how can I turn?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847215#M334966</link>
      <description>&lt;P&gt;Thanks, thats it. Sorry for re-mention this topic, I obviously did not use the best keys for my search&lt;/P&gt;</description>
      <pubDate>Thu, 01 Dec 2022 09:02:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-vbar-stacked-axistable-always-in-reverse-order-how/m-p/847215#M334966</guid>
      <dc:creator>USchu</dc:creator>
      <dc:date>2022-12-01T09:02:51Z</dc:date>
    </item>
  </channel>
</rss>

