<?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 Order xaxis by descending frequency in sgplot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163988#M6129</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some data on adverse events that I'd like to show in sgplot. I want the xaxis to be ordered by descending frequency. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use the &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CATEGORYORDER=RESPDESC&lt;/SPAN&gt; it works. However, when I want to group the vbar this option is ignored.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=AE_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; vbar site_ID / &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CATEGORYORDER=RESPDESC&lt;/SPAN&gt; group=severity ;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I do not want to use discreteorder=data because this will order the data by Site_ID, not by the frequency of site_id. &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;How do I get an output with the vbar sorted by frequency of site_id?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 02 Jul 2014 15:52:08 GMT</pubDate>
    <dc:creator>sarahsasuser</dc:creator>
    <dc:date>2014-07-02T15:52:08Z</dc:date>
    <item>
      <title>Order xaxis by descending frequency in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163988#M6129</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have some data on adverse events that I'd like to show in sgplot. I want the xaxis to be ordered by descending frequency. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I use the &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CATEGORYORDER=RESPDESC&lt;/SPAN&gt; it works. However, when I want to group the vbar this option is ignored.&amp;nbsp; &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sgplot data=AE_data;&lt;/P&gt;&lt;P&gt;&amp;nbsp; vbar site_ID / &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;CATEGORYORDER=RESPDESC&lt;/SPAN&gt; group=severity ;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;I do not want to use discreteorder=data because this will order the data by Site_ID, not by the frequency of site_id. &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;How do I get an output with the vbar sorted by frequency of site_id?&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 15:52:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163988#M6129</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2014-07-02T15:52:08Z</dc:date>
    </item>
    <item>
      <title>Re: Order xaxis by descending frequency in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163989#M6130</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, I see the problem.&amp;nbsp; When GROUP is specified, you are getting group order of descending response, but discrete order of ascending (default).&amp;nbsp; This is a bug we will need to addess.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The way out I see is to summarize the data using proc means, sort by descending (sum of) frequencies and then use VBAR to draw the data with N as the response variable and DiscreteOrder=Data.&amp;nbsp; Here is an example.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="FreqPlot.png" class="jive-image-thumbnail jive-image" src="https://communities.sas.com/legacyfs/online/6765_FreqPlot.png" width="450" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 18:35:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163989#M6130</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2014-07-02T18:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Order xaxis by descending frequency in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163990#M6131</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Sanjay. Because the data are character, I ran a PROC FREQ on the site_id, output those counts to a dataset, and merged this new freq dataset with the original dataset. Then I sorted on frequency before plotting. Is there an easier/smarter way to obtain frequencies without merging the output and original datasets? I have multiple variables that I need to graph and then plot by descending frequency in this dataset. Therefore, I'm running several frequencies and outputing to multiple datasets and then merging these datasets with the original. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 20:46:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163990#M6131</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2014-07-02T20:46:09Z</dc:date>
    </item>
    <item>
      <title>Re: Order xaxis by descending frequency in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163991#M6132</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I did it a little differently.&amp;nbsp; My code is attached.&amp;nbsp; Only issue in this case is that the segments within the bars are not correctly sorted in descending order due to another bug in SGPLOT.&amp;nbsp; :smileyplain:&amp;nbsp; But, if you don't care about that, you are good to go.&amp;nbsp; If you do care about it, then you need another adjustment.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 02 Jul 2014 21:19:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163991#M6132</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2014-07-02T21:19:07Z</dc:date>
    </item>
    <item>
      <title>Re: Order xaxis by descending frequency in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163992#M6133</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If sgplot can't easily create the chart you want, perhaps Proc Gchart would be a better choice?...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc gchart data=sashelp.cars;&lt;/P&gt;&lt;P&gt;vbar type / type=freq outside=freq subgroup=origin descending;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="foo.png" class="jive-image-thumbnail jive-image" height="421" src="https://communities.sas.com/legacyfs/online/6773_foo.png" width="576" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 15:12:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163992#M6133</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2014-07-03T15:12:13Z</dc:date>
    </item>
    <item>
      <title>Re: Order xaxis by descending frequency in sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163993#M6134</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, that's much easier. Using SGPLOT, I have to create frequency datasets, merge those datasets with the original, and then plot. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 03 Jul 2014 19:50:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Order-xaxis-by-descending-frequency-in-sgplot/m-p/163993#M6134</guid>
      <dc:creator>sarahsasuser</dc:creator>
      <dc:date>2014-07-03T19:50:13Z</dc:date>
    </item>
  </channel>
</rss>

