<?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 How to sort boxplots by the median in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/285857#M58526</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS (coming from R) and i would like to sort&amp;nbsp;boxplot by the median of the variable being plotted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code i have generated using SAS Enterprise is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;PROC SQL;&lt;BR /&gt;CREATE VIEW WORK.SORTTempTableSorted AS&lt;BR /&gt;SELECT T.Country, T.BUFF&lt;BR /&gt;FROM WORK.QUERY_FOR_PROFITABILITY_MI as T&lt;BR /&gt;WHERE BUFF BETWEEN -5 AND 5&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;SYMBOL1 INTERPOL=BOXTJF VALUE=CIRCLE&lt;BR /&gt;HEIGHT=1&lt;BR /&gt;MODE=EXCLUDE&lt;BR /&gt;;&lt;BR /&gt;Axis1&lt;BR /&gt;STYLE=1&lt;BR /&gt;WIDTH=1&lt;BR /&gt;MINOR=NONE&lt;BR /&gt;&lt;BR /&gt;;&lt;BR /&gt;Axis2&lt;BR /&gt;STYLE=1&lt;BR /&gt;WIDTH=1&lt;BR /&gt;MINOR=NONE&lt;BR /&gt;&lt;BR /&gt;VALUE=(ANGLE=90)&lt;BR /&gt;;&lt;BR /&gt;TITLE;&lt;BR /&gt;TITLE1 "Box Plot";&lt;BR /&gt;FOOTNOTE;&lt;BR /&gt;FOOTNOTE1 "Generated by the SAS System (&amp;amp;_SASSERVERNAME, &amp;amp;SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";&lt;BR /&gt;PROC GPLOT DATA=WORK.SORTTempTableSorted&lt;BR /&gt;;&lt;BR /&gt;PLOT BUFF * Country/&lt;BR /&gt;VAXIS=AXIS1&lt;BR /&gt;&lt;BR /&gt;HAXIS=AXIS2&lt;BR /&gt;&lt;BR /&gt;GRID&lt;BR /&gt;;&lt;BR /&gt;/* -------------------------------------------------------------------&lt;BR /&gt;End of task code.&lt;BR /&gt;------------------------------------------------------------------- */&lt;BR /&gt;RUN; QUIT;&lt;BR /&gt;%_eg_conditional_dropds(WORK.SORTTempTableSorted);&lt;BR /&gt;TITLE; FOOTNOTE;&lt;BR /&gt;GOPTIONS RESET = SYMBOL;%SYMDEL _CLIENTTASKFILTER;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to modify such&amp;nbsp;code in order to get the desired order of the boxplots?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 20 Jul 2016 16:14:52 GMT</pubDate>
    <dc:creator>spenna</dc:creator>
    <dc:date>2016-07-20T16:14:52Z</dc:date>
    <item>
      <title>How to sort boxplots by the median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/285857#M58526</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am new to SAS (coming from R) and i would like to sort&amp;nbsp;boxplot by the median of the variable being plotted.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code i have generated using SAS Enterprise is the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-SPOILER&gt;PROC SQL;&lt;BR /&gt;CREATE VIEW WORK.SORTTempTableSorted AS&lt;BR /&gt;SELECT T.Country, T.BUFF&lt;BR /&gt;FROM WORK.QUERY_FOR_PROFITABILITY_MI as T&lt;BR /&gt;WHERE BUFF BETWEEN -5 AND 5&lt;BR /&gt;;&lt;BR /&gt;QUIT;&lt;BR /&gt;SYMBOL1 INTERPOL=BOXTJF VALUE=CIRCLE&lt;BR /&gt;HEIGHT=1&lt;BR /&gt;MODE=EXCLUDE&lt;BR /&gt;;&lt;BR /&gt;Axis1&lt;BR /&gt;STYLE=1&lt;BR /&gt;WIDTH=1&lt;BR /&gt;MINOR=NONE&lt;BR /&gt;&lt;BR /&gt;;&lt;BR /&gt;Axis2&lt;BR /&gt;STYLE=1&lt;BR /&gt;WIDTH=1&lt;BR /&gt;MINOR=NONE&lt;BR /&gt;&lt;BR /&gt;VALUE=(ANGLE=90)&lt;BR /&gt;;&lt;BR /&gt;TITLE;&lt;BR /&gt;TITLE1 "Box Plot";&lt;BR /&gt;FOOTNOTE;&lt;BR /&gt;FOOTNOTE1 "Generated by the SAS System (&amp;amp;_SASSERVERNAME, &amp;amp;SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";&lt;BR /&gt;PROC GPLOT DATA=WORK.SORTTempTableSorted&lt;BR /&gt;;&lt;BR /&gt;PLOT BUFF * Country/&lt;BR /&gt;VAXIS=AXIS1&lt;BR /&gt;&lt;BR /&gt;HAXIS=AXIS2&lt;BR /&gt;&lt;BR /&gt;GRID&lt;BR /&gt;;&lt;BR /&gt;/* -------------------------------------------------------------------&lt;BR /&gt;End of task code.&lt;BR /&gt;------------------------------------------------------------------- */&lt;BR /&gt;RUN; QUIT;&lt;BR /&gt;%_eg_conditional_dropds(WORK.SORTTempTableSorted);&lt;BR /&gt;TITLE; FOOTNOTE;&lt;BR /&gt;GOPTIONS RESET = SYMBOL;%SYMDEL _CLIENTTASKFILTER;&lt;/LI-SPOILER&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a way to modify such&amp;nbsp;code in order to get the desired order of the boxplots?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any help!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Jul 2016 16:14:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/285857#M58526</guid>
      <dc:creator>spenna</dc:creator>
      <dc:date>2016-07-20T16:14:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort boxplots by the median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/285946#M58568</link>
      <description>Hello,&lt;BR /&gt;Can i know whether did you find out the median of the variable which you want to plot? You can use Proc univariate or Proc means in order to get a median of variable.</description>
      <pubDate>Wed, 20 Jul 2016 19:45:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/285946#M58568</guid>
      <dc:creator>skg74_mail_umkc_edu</dc:creator>
      <dc:date>2016-07-20T19:45:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort boxplots by the median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/286029#M58594</link>
      <description>&lt;P&gt;Rick'blog have such an example .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2014/09/10/viz-distributions-of-100-vars.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2014/09/10/viz-distributions-of-100-vars.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4152i66299F003104844C/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 02:55:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/286029#M58594</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-21T02:55:47Z</dc:date>
    </item>
    <item>
      <title>Re: How to sort boxplots by the median</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/286034#M58595</link>
      <description>&lt;P&gt;Give you an example. If you have SAS9.4 ,that would be more easy by using SQL.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data class;
 set sashelp.heart;
 array x{*} _numeric_;
 do i=1 to dim(x);
  vname=vname(x{i});
  value=x{i};
  output;
 end;
 keep vname value;
run;
proc sort data=class;by vname;run;
proc summary data=class;
 by vname;
 var value;
 output out=median(drop=_:) median=median;
run;
data want;
 merge class median;
 by vname;
run;
proc sort data=want;by median;run;

proc sgplot data=want ;
 vbox value/category=vname;
 xaxis discreteorder=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4154iCEE8CA653296BA15/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jul 2016 03:37:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-sort-boxplots-by-the-median/m-p/286034#M58595</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-21T03:37:35Z</dc:date>
    </item>
  </channel>
</rss>

