<?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: Boxplot for different treatments in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427006#M68405</link>
    <description>&lt;P&gt;You would need to transpose the data so that each treatment is a single record with a variable to contain a treatment identifier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like:&lt;/P&gt;
&lt;PRE&gt;data plot;
   set my data;
   TreatName='Treatment 1'; Value=Treatment1;output;
   TreatName='Treatment 2'; Value=Treatment2;output;
   drop treatment1 treatment2;
run;&lt;/PRE&gt;
&lt;P&gt;and plot by TreatName *time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jan 2018 20:57:54 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2018-01-11T20:57:54Z</dc:date>
    <item>
      <title>Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/426996#M68403</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to get a boxplot figure like the following:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17803iBAEAE05C890099F4/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;My dataset include thousands of stations, and for each station it have results for 2 treatments (similar as&amp;nbsp;&amp;nbsp;black and blue in the figure) and 12&amp;nbsp;months (Jan to Dec) and a total as annual (x-axis has 13 labels).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The variables in&amp;nbsp;my dataset are: &amp;nbsp;station&amp;nbsp;time(Jan-Dec,Ann) &amp;nbsp;Treatment1 Treatment2&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyone has any idea about how to get the figure?&lt;/P&gt;
&lt;P&gt;By the way, I used the following code, but could only do it one treatment by one treatment.&lt;/P&gt;
&lt;PRE&gt;proc sort data = mydata;
  by time;
run;

proc boxplot data = mydata;
  plot treatment1 * time;
run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:28:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/426996#M68403</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2018-01-11T20:28:02Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427006#M68405</link>
      <description>&lt;P&gt;You would need to transpose the data so that each treatment is a single record with a variable to contain a treatment identifier&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try something like:&lt;/P&gt;
&lt;PRE&gt;data plot;
   set my data;
   TreatName='Treatment 1'; Value=Treatment1;output;
   TreatName='Treatment 2'; Value=Treatment2;output;
   drop treatment1 treatment2;
run;&lt;/PRE&gt;
&lt;P&gt;and plot by TreatName *time&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 20:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427006#M68405</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-11T20:57:54Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427010#M68406</link>
      <description>Plot by TreatName*time doesn't work, it shows an error that The variable TreatName in the DATA= data set should be a numeric variable.&lt;BR /&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:03:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427010#M68406</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2018-01-11T21:03:42Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427016#M68407</link>
      <description>&lt;P&gt;Try moving to the more updated graphics where you can use numeric or text values for grouping and categorizing:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=plot;
   vbox value /  category=time group=treatname;
run;&lt;/PRE&gt;
&lt;P&gt;This uses ODS graphics options so if the display is too narrow or what have you the size can be adjusted with Height and Width options:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ODS graphics / height=4in width=8in;&lt;/P&gt;
&lt;P&gt;proc sgplot ..&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;would have a display 8 inches wide and 4 inches tall for example.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:13:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427016#M68407</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-11T21:13:16Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427021#M68409</link>
      <description>&lt;P&gt;And after transpose my data by:&lt;/P&gt;
&lt;PRE&gt;data plot;
   set mydata;
   TreatName='Treatment 1'; Value=Treatment1;output;
   TreatName='Treatment 2'; Value=Treatment2;output;
   drop treatment1 treatment2;
run;&lt;/PRE&gt;
&lt;P&gt;I used&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=plot;
   vbox value / category=time group=TreatName;
run;&lt;/PRE&gt;
&lt;P&gt;I got the figures &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/17804i1ED21ED1D69FD4ED/image-size/large?v=v2&amp;amp;px=999" role="button" title="2.png" alt="2.png" /&gt;&lt;/span&gt;, but I want to have max and min as a line without outliers, and also want to get the line at value 0.&lt;/P&gt;
&lt;P&gt;Also, anyone know how to use two axis instead of only one?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:16:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427021#M68409</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2018-01-11T21:16:43Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427024#M68410</link>
      <description>Yes, I tried these codes! it works. But do you know how to use max/min instead of outliers? And get the line y=0?</description>
      <pubDate>Thu, 11 Jan 2018 21:19:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427024#M68410</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2018-01-11T21:19:35Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427027#M68411</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55231"&gt;@hua&lt;/a&gt; wrote:&lt;BR /&gt;
&lt;P&gt;, but I want to have max and min as a line without outliers, and also want to get the line at value 0.&lt;/P&gt;
&lt;P&gt;Also, anyone know how to use two axis instead of only one?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;You would have to explain HOW you want to use two axis.&lt;/P&gt;
&lt;P&gt;There are a fair number of options in the online help for the VBOX statement in SGPLOT.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Such as EXTREME to show max and min lines to the maximum and minimum as an option on the vbox statement&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Refline 0 / axis=y; will dray a line at y=0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have to say from you graph that the two treatments don't belong in the same graph as the ranges are significantly different;&lt;/P&gt;
&lt;P&gt;Perhaps Proc SGPANEL with:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; panelby treatname / onepanel rows=2 uniscale=column;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:30:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427027#M68411</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-11T21:30:09Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427029#M68412</link>
      <description>Thanks! I will check the options online. The ranges are so different, that's why I want to use two y-axises, one for each.</description>
      <pubDate>Thu, 11 Jan 2018 21:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427029#M68412</guid>
      <dc:creator>hua</dc:creator>
      <dc:date>2018-01-11T21:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: Boxplot for different treatments</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427037#M68416</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/55231"&gt;@hua&lt;/a&gt; wrote:&lt;BR /&gt;Thanks! I will check the options online. The ranges are so different, that's why I want to use two y-axises, one for each.&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I don't think you'll be happy with the results of any of the 2 axis solutions with the modified data. I recommended modifying the data as that would be needed for the older boxplot for many approaches.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might go back to the original data and try overlaying two vbox statements as that is one of the big improvements with the SGgraphics. You can't overlay just anything but two vbox should work:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sgplot data= mydata;
   vbox treatment1 / category=time
                     extreme
                     
   ;
   vbox treatment2 / category=time 
                     extreme
                     y2axis
   ;
   refline 0;
run;&lt;/PRE&gt;</description>
      <pubDate>Thu, 11 Jan 2018 21:48:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Boxplot-for-different-treatments/m-p/427037#M68416</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-01-11T21:48:59Z</dc:date>
    </item>
  </channel>
</rss>

