<?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: Ordering bars in ascending response summary sequence in a barchart in ODS and Base Reporting</title>
    <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393364#M19247</link>
    <description>&lt;P&gt;Sorry, using 9.4 M4. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sure that would work. &amp;nbsp;Unfortunately the actual code is part of a larger proc template begingraph block that I can't separate out. &amp;nbsp;Otherwise I would have used something simpler, like the gchart approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;</description>
    <pubDate>Tue, 05 Sep 2017 20:46:56 GMT</pubDate>
    <dc:creator>BenConner</dc:creator>
    <dc:date>2017-09-05T20:46:56Z</dc:date>
    <item>
      <title>Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393342#M19245</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to emulate something like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc gchart data=sashelp.baseball;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; hbar team / asc sumvar=natbat;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;in a proc template. &amp;nbsp;I can get the vertical bars to come out but not in ascending sequence by the sum of the response variable. &amp;nbsp;How can I get it to come out in order?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Current code:&lt;/P&gt;
&lt;P&gt;proc template;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; define statgraph bb;&lt;BR /&gt;&amp;nbsp; begingraph;&lt;BR /&gt;&amp;nbsp; layout overlay /;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;barchart response=natbat category=team;&lt;BR /&gt;&amp;nbsp; endlayout;&lt;BR /&gt;&amp;nbsp; endgraph;&lt;BR /&gt;&amp;nbsp; end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgrender data=sashelp.baseball template=bb;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 19:03:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393342#M19245</guid>
      <dc:creator>BenConner</dc:creator>
      <dc:date>2017-09-05T19:03:32Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393361#M19246</link>
      <description>&lt;P&gt;Something like this? Version of SAS you are using can make this problematic as I think the categoryorder is a relatively recent option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.baseball;
   vbar team/response=natbat stat=sum
            categoryorder=respasc;
run; &lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Sep 2017 21:08:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393361#M19246</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-05T21:08:14Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393364#M19247</link>
      <description>&lt;P&gt;Sorry, using 9.4 M4. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm sure that would work. &amp;nbsp;Unfortunately the actual code is part of a larger proc template begingraph block that I can't separate out. &amp;nbsp;Otherwise I would have used something simpler, like the gchart approach.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 20:46:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393364#M19247</guid>
      <dc:creator>BenConner</dc:creator>
      <dc:date>2017-09-05T20:46:56Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393372#M19248</link>
      <description>&lt;P&gt;If that gets you started then you might add the TMPLOUT="filename" option to the proc statement. That will create a text file with the template code to generate the given graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It goes help to provide a more complete example of where you are going with this as it may avoid pitfalls like attempting to use a Layout Gridded where you want Layout Datalattice or ...&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 21:06:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393372#M19248</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-05T21:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393384#M19249</link>
      <description>&lt;P&gt;Of course. &amp;nbsp;I always forget that as an option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The part I couldn't find was&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;yaxisopts=(discreteOpts=(sortOrder=Data))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;that got me what I needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks so much!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 21:55:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393384#M19249</guid>
      <dc:creator>BenConner</dc:creator>
      <dc:date>2017-09-05T21:55:24Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393394#M19250</link>
      <description>&lt;P&gt;Tried the tmplout= option and it generated the following code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc template;&lt;BR /&gt;define statgraph sgplot;&lt;BR /&gt;dynamic _NEGATIVE_;&lt;BR /&gt;dynamic _ticklist_;&lt;BR /&gt;begingraph / collation=binary;&lt;BR /&gt;layout overlay / yaxisopts=(discreteOpts=(sortOrder=Data)) &lt;BR /&gt; yaxisopts=(labelFitPolicy=Split) y2axisopts=(labelFitPolicy=Split) &lt;BR /&gt; yaxisopts=(type=Discrete reverse=true discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union)) &lt;BR /&gt; y2axisopts=(type=Discrete reverse=true discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union));&lt;BR /&gt; BarChartParm X=Team Y=_Sum1_nAtBat_ / primary=true orient=horizontal LegendLabel="Times at Bat in 1986" NAME="HBAR";&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I ran that with an sgrender per:&lt;/P&gt;
&lt;P&gt;proc sgrender data=sashelp.baseball template=sgplot; &amp;nbsp; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That didn't go anywhere due to the 2 dynamic variables. &amp;nbsp;I commented out the _ticklist_ dynamic variable and the reference to it but I'm not sure how to handle the _NEGATIVE_ reference. &amp;nbsp;Also, is the _Sum1_nAtBat_ a variable from a temporary file that is created? &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Tried a few more variants with no success. &amp;nbsp;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;</description>
      <pubDate>Tue, 05 Sep 2017 22:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393394#M19250</guid>
      <dc:creator>BenConner</dc:creator>
      <dc:date>2017-09-05T22:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393606#M19256</link>
      <description>&lt;P&gt;Note that the template uses Barchartparm. That element requires presummarized data. So the SGPLOT internally summarizes the data.&lt;/P&gt;
&lt;P&gt;So you need to summarize the data as well as remove the offending dynamic variables.&lt;/P&gt;
&lt;PRE&gt;proc template;
   define statgraph baseballplot;
/*   dynamic _NEGATIVE_;*/
/*   dynamic _ticklist_;*/
   begingraph / collation=binary;
      layout overlay / 
         yaxisopts=(discreteOpts=(sortOrder=Data)) 
         yaxisopts=(labelFitPolicy=Split) 
         y2axisopts=(labelFitPolicy=Split) 
         yaxisopts=(type=Discrete reverse=true /*discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union)*/) 
         y2axisopts=(type=Discrete reverse=true /* discreteOpts=(tickValueList=_ticklist_ tickValueListPolicy=Union)*/);
         BarChartParm X=Team Y=_Sum1_nAtBat_ / primary=true orient=horizontal LegendLabel="Times at Bat in 1986" NAME="HBAR";
      endlayout;
   endgraph;
end;
run;
proc summary data=sashelp.baseball nway;
   class team;
   var natbat;
   output out= basesum sum=_sum1_natbat_;
run;
Proc sort data=basesum;
   by _sum1_natbat_;
run;

proc sgrender data=basesum template=baseballplot;
  ;
run;&lt;/PRE&gt;
&lt;P&gt;If you don't like the ugly _sum1_natbat_ variable name then change it in the tempplate and the proc summary code.&lt;/P&gt;
&lt;P&gt;Better would likely be to replace Team, _sum1_natbat_ and legendlable text&amp;nbsp;with dynamic variables to use the template&amp;nbsp;more flexibly&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 15:46:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393606#M19256</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-06T15:46:00Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393613#M19258</link>
      <description>&lt;P&gt;The production code will be a lot cleaner. &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Substituting the following, building on the output from the generated template:&lt;/P&gt;
&lt;P&gt;proc summary data=sashelp.baseball nway; &lt;BR /&gt; class team; &lt;BR /&gt; var natbat; &lt;BR /&gt; output out=sumbb sum=; &lt;BR /&gt;run; &lt;BR /&gt;proc sort data=sumbb; &lt;BR /&gt; by descending natbat; &lt;BR /&gt;run; &lt;BR /&gt;proc template; &lt;BR /&gt; define statgraph sgplot; &lt;BR /&gt; begingraph / collation=binary; &lt;BR /&gt; layout overlay / yaxisopts=(discreteOpts=(sortOrder=Data)) &lt;BR /&gt; yaxisopts=(labelFitPolicy=Split) y2axisopts=(labelFitPolicy=Split) ; &lt;BR /&gt; BarChartParm X=Team Y=nAtBat / primary=true orient=horizontal LegendLabel="Times at Bat in 1986" NAME="HBAR"; &lt;BR /&gt; endlayout; &lt;BR /&gt; endgraph; &lt;BR /&gt; end; &lt;BR /&gt;run; &lt;BR /&gt;proc sgrender data=sumbb template=sgplot; &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is what worked. &amp;nbsp;It sorts the response values in ascending order in the graph. &amp;nbsp;I'm just not sure why....as I had to use descending in the proc sort to make it work. ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 16:08:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393613#M19258</guid>
      <dc:creator>BenConner</dc:creator>
      <dc:date>2017-09-06T16:08:59Z</dc:date>
    </item>
    <item>
      <title>Re: Ordering bars in ascending response summary sequence in a barchart</title>
      <link>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393689#M19261</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is what worked. &amp;nbsp;It sorts the response values in ascending order in the graph. &amp;nbsp;I'm just not sure why....as I had to use descending in the proc sort to make it work. ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--Ben&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Probably just the way you think of HBAR order and the procedure coding isn't quite intuitive for you. If you want the longest bar at the top that is the largest value=descending sort order (top to bottom), if you want the longest bar at the bottom that is the largest value =ascending sort order&lt;/P&gt;</description>
      <pubDate>Wed, 06 Sep 2017 19:28:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/ODS-and-Base-Reporting/Ordering-bars-in-ascending-response-summary-sequence-in-a/m-p/393689#M19261</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-09-06T19:28:05Z</dc:date>
    </item>
  </channel>
</rss>

