<?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: How to make boxplot for multiple variables with subgroups in SAS? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238565#M8652</link>
    <description>&lt;P&gt;If you have SAS 9.3, you can use the SGPLOT procedure with a VBOX statement grouped by Age (binary varialbe).. Isuggest transpose your data so a, b, c, d and e become a category, with their values in a variable called Value. &amp;nbsp;YOu already have Age. &amp;nbsp;Plot VBOX value / category=cat group=age;&lt;/P&gt;</description>
    <pubDate>Wed, 09 Dec 2015 19:47:15 GMT</pubDate>
    <dc:creator>Jay54</dc:creator>
    <dc:date>2015-12-09T19:47:15Z</dc:date>
    <item>
      <title>How to make boxplot for multiple variables with subgroups in SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238563#M8651</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a dataset "baseline" with continuous variables a, b, c, d and e. And I also have a binary variable age (young, old). I would like to create a plot that contains boxplots for a, b, c, d and e within each group of age. Originally, my code looks like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc template;&lt;BR /&gt;define statgraph boxplot_age;&lt;BR /&gt;begingraph;&lt;BR /&gt;layout overlay / xaxisopts=(display=(ticks tickvalues))&lt;BR /&gt;yaxisopts=(griddisplay=on) cycleattrs=true;&lt;BR /&gt;boxplot x=age y=a /discreteoffset=-0.3 boxwidth=0.1&lt;BR /&gt;name='a' legendlabel='a';&lt;BR /&gt;boxplot x=age y=b / discreteoffset= -0.15 boxwidth=0.1&lt;BR /&gt;name='b' legendlabel='b';&lt;BR /&gt;boxplot x=age y=c / discreteoffset=0 boxwidth=0.1&lt;BR /&gt;name='b' legendlabel='c';&lt;BR /&gt;boxplot x=age y=d / discreteoffset= 0.15 boxwidth=0.1&lt;BR /&gt;name='d' legendlabel='d';&lt;BR /&gt;boxplot x=age y=e / discreteoffset= 0.3 boxwidth=0.1&lt;BR /&gt;name='e' legendlabel='e';&lt;BR /&gt;discretelegend 'a' 'b' 'c' 'd' 'e';&lt;BR /&gt;endlayout;&lt;BR /&gt;endgraph;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;proc sgrender data=baseline name=boxplot_age template=boxplot_age;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, what I actually want is to view the value of each variable by age group side by side. For example, I would want a boxplot for varible "a", age=young followed by a boxplot for variable "a", age=old and then followed by a boxplot for variable "b", age=young and so on.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if this is even possible to do in SAS. Any comment would be appreciated and let me know if my question is not clear.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many thanks!&lt;/P&gt;&lt;P&gt;Gordon&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 19:34:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238563#M8651</guid>
      <dc:creator>GordonC</dc:creator>
      <dc:date>2015-12-09T19:34:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to make boxplot for multiple variables with subgroups in SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238565#M8652</link>
      <description>&lt;P&gt;If you have SAS 9.3, you can use the SGPLOT procedure with a VBOX statement grouped by Age (binary varialbe).. Isuggest transpose your data so a, b, c, d and e become a category, with their values in a variable called Value. &amp;nbsp;YOu already have Age. &amp;nbsp;Plot VBOX value / category=cat group=age;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 19:47:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238565#M8652</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2015-12-09T19:47:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to make boxplot for multiple variables with subgroups in SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238570#M8653</link>
      <description>&lt;P&gt;I see what you mean. It is a great idea. Just to be clear, I only transpose a,b,c,d and e so that I will have a "catagory" variable and a "value" variable. I also have age for each subject so I can merge "age" to the transposed data by subject id. And finially my code will look like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=baseline_t;&lt;BR /&gt;vbox value / category=cat group=age ;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope It is correct!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 20:01:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238570#M8653</guid>
      <dc:creator>GordonC</dc:creator>
      <dc:date>2015-12-09T20:01:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to make boxplot for multiple variables with subgroups in SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238572#M8654</link>
      <description>&lt;P&gt;I think the best approach to handle this situation is to transpose your data such that the column names are values in a column. A simple examples is below. In your case, the "a-e" variable would be used in place of "weight" and "height", and you would use your "age" variable instead of "sex".&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data class;&lt;BR /&gt;length cat $ 6;&lt;BR /&gt;set sashelp.class;&lt;BR /&gt;cat="weight"; value=weight; output;&lt;BR /&gt;cat="height"; value=height; output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=class;&lt;BR /&gt;vbox value / category=cat group=sex groupdisplay=cluster;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 20:17:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238572#M8654</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2015-12-09T20:17:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to make boxplot for multiple variables with subgroups in SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238577#M8655</link>
      <description>&lt;P&gt;Awesome! Thank you so much for the help!&lt;/P&gt;</description>
      <pubDate>Wed, 09 Dec 2015 21:02:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-make-boxplot-for-multiple-variables-with-subgroups-in-SAS/m-p/238577#M8655</guid>
      <dc:creator>GordonC</dc:creator>
      <dc:date>2015-12-09T21:02:50Z</dc:date>
    </item>
  </channel>
</rss>

