<?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: GTL: Barchart sorted by Frequencies in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78389#M2920</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A name="p046omhskz3h9zn1qodlpxfdm3hl"&gt;&lt;/A&gt;From the doc: "By default, if the category is character, the bars in the chart appear in the order in which the category values are present in the input data."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 15 Mar 2013 15:58:26 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2013-03-15T15:58:26Z</dc:date>
    <item>
      <title>GTL: Barchart sorted by Frequencies</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78388#M2919</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;gt;&amp;gt; I originally posted this on the ODS board and was recommended to repost this here. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I hope I'm not missing an easy answer, but it's not for lack of diligence. I'm trying to use GTL to define a fairly basic horizontal bar chart. For the life of me I can't find an option to allow me to sort the bars by frequency. Is there an equivalent GTL option to CATEGORYORDER=RESPDESC? I suspect there is since this is would be a common need.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc template;&lt;/P&gt;&lt;P&gt;define statgraph FlagBarCharts;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamic byvar;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; begingraph;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrytitle "Flag Variable:&amp;nbsp; "&amp;nbsp; byvar ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layout overlay &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; border=false &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WALLDISPLAY=none&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xaxisopts=(&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label=' ' &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; linearopts=(viewmax=10));&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BARCHARTPARM x=subcat y=percent &lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / orient=horizontal;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endlayout;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; endgraph;&lt;/P&gt;&lt;P&gt;end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 15:44:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78388#M2919</guid>
      <dc:creator>bob_pearson</dc:creator>
      <dc:date>2013-03-15T15:44:44Z</dc:date>
    </item>
    <item>
      <title>Re: GTL: Barchart sorted by Frequencies</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78389#M2920</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;A name="p046omhskz3h9zn1qodlpxfdm3hl"&gt;&lt;/A&gt;From the doc: "By default, if the category is character, the bars in the chart appear in the order in which the category values are present in the input data."&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 15:58:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78389#M2920</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2013-03-15T15:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: GTL: Barchart sorted by Frequencies</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78390#M2921</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Such an option is coming soon.&amp;nbsp; In the meantime, you can do this is by getting the frequencies using PROC FREQ, sort as needed, then use the SGPLOT HBAR or GTL BARCHART to draw the bars.&amp;nbsp; GTL will retain data order by default.&amp;nbsp; For SGPLOT will order your categories by default.&amp;nbsp; You have to set XAXIS DISCRETEORDER to DATA.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 16:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78390#M2921</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2013-03-15T16:02:50Z</dc:date>
    </item>
    <item>
      <title>Re: GTL: Barchart sorted by Frequencies</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78391#M2922</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If it's termed the default behavior, does that mean that there are options? ...or is that what BARCHART always does? If so then the user must manually sort the data. It seems as though that would be more easily handled at graph time, moreso for BARCHART than BARCHARTPARM, and the option would be frequently needed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Bob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 16:16:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78391#M2922</guid>
      <dc:creator>bob_pearson</dc:creator>
      <dc:date>2013-03-15T16:16:25Z</dc:date>
    </item>
    <item>
      <title>Re: GTL: Barchart sorted by Frequencies</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78392#M2923</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Just saw your post Sanjay after I replied. Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 16:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78392#M2923</guid>
      <dc:creator>bob_pearson</dc:creator>
      <dc:date>2013-03-15T16:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: GTL: Barchart sorted by Frequencies</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78393#M2924</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Hi&amp;nbsp; Bob,&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Copying my response from the original thread, did you try it and get different results that you wanted?&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I saw your response that the linearopts applied to the response axis.&amp;nbsp; But since your BARCHARTPARM was x=subcat, I think xaxisopts applies to the x axis, which in this case is the vertical axis because it's a horizontal plot.&amp;nbsp; When I ran the code with linearopts removed from the xaxisopts, and then sorted the data, it seemed to give the result you wanted (consistent with Sanjay's note that GTL would user data order by default).&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;My original response:&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;I'm new to GTL, but I think if you remove the linearopts= option, then the categories will be ordered according to the order of the input dataset.&amp;nbsp; I guess when you added linearopts=, it forced the xaxis to be linear, instead of categorical.&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;/P&gt;&lt;PRE&gt;proc template;
define statgraph FlagBarCharts;
&amp;nbsp;&amp;nbsp;&amp;nbsp; dynamic byvar;
&amp;nbsp;&amp;nbsp;&amp;nbsp; begingraph;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; entrytitle "Flag Variable:&amp;nbsp; "&amp;nbsp; byvar ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; layout overlay 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; border=false 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; WALLDISPLAY=none
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; xaxisopts=(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; label=' ' 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; );
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BARCHARTPARM x=subcat y=percent 
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; / orient=horizontal ;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; endlayout;
&amp;nbsp;&amp;nbsp;&amp;nbsp; endgraph;
end;

run;

data in;
&amp;nbsp; subcat='1'; percent=2; output;
&amp;nbsp;&amp;nbsp;&amp;nbsp; subcat='2'; percent=6; output;
&amp;nbsp;&amp;nbsp;&amp;nbsp; subcat='3'; percent=4;output;
run;

proc sort data=in;
&amp;nbsp; by percent;
run;

ods pdf file="d:\junk\me.pdf";
proc sgrender data=in template=FlagBarcharts;
run;
ods pdf close;
&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 15 Mar 2013 19:22:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/GTL-Barchart-sorted-by-Frequencies/m-p/78393#M2924</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2013-03-15T19:22:45Z</dc:date>
    </item>
  </channel>
</rss>

