<?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: Creating boxplots in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/738419#M21471</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="boxplot.png" style="width: 254px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58932i72284B26B24E08F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="boxplot.png" alt="boxplot.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname test  '~/test';
/* proc print data=test.test7; */
run;
data x;
   set test.test7;
     id=_n_;
 run;
proc transpose data=x out=tran (rename=(_name_=var col1=value) drop=_label_);
  by id;
  var var: ;  
label var='Box Variables';
run; 
proc sgplot data=tran;
title 'SGPLOT';
vbox value / category=var;
/*   replace category with group for different color bars */
run;
proc sgpanel data=tran ;
title 'SGPanel';
  panelby var / COLUMNS=3;
  vbox value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Sun, 02 May 2021 17:52:30 GMT</pubDate>
    <dc:creator>ghosh</dc:creator>
    <dc:date>2021-05-02T17:52:30Z</dc:date>
    <item>
      <title>Creating boxplots</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737827#M21463</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;I will like to create a boxplot for the following 3 variables (var1, var2, var3) as in the table attached. Is there any way to achieve that? they should be displayed side by side in one diagramm&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 09:20:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737827#M21463</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2021-04-29T09:20:52Z</dc:date>
    </item>
    <item>
      <title>Re: Creating boxplots</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737841#M21464</link>
      <description>&lt;P&gt;I don't download files, so I can't see your attachment.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will assume that you have three different columns you want in a box plot. You need to transpose this data set to a long data set so the values are in one column, and new variable contains a text string indicating the name of your original variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then, use PROC SGPLOT with the VBOX statement and the CLASS= option. (For CLASS=, use the name of the new variable that contains the name of your original variables)&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 10:36:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737841#M21464</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2021-04-29T10:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Creating boxplots</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737862#M21465</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I don't download attachments either.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So I cannot see your data.&lt;/P&gt;
&lt;P&gt;However, here's an example of what you are trying to do (I believe).&lt;/P&gt;
&lt;P&gt;The Overall Statistics don't make any sense (in this specific use case) but it's just to show you something more about PROC BOXPLOT.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Height;
 set sashelp.class(keep=height);
run;
data Weight;
 set sashelp.class(keep=weight);
run;
data HW;
 set Height(rename=(height=Var_to_Plot) in=a) 
     Weight(rename=(weight=Var_to_Plot) in=b);
 if a      then category='H';
 else if b then category='W';
 else;
run;

proc boxplot data=HW;
   plot Var_to_Plot*category;
   inset min mean max stddev /
      header = 'Overall Statistics'
      pos    = tm;
   insetgroup min max /
      header = 'Extremes by Category';
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 11:30:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737862#M21465</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-04-29T11:30:42Z</dc:date>
    </item>
    <item>
      <title>Re: Creating boxplots</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737880#M21466</link>
      <description>&lt;P&gt;For those reluctant to download the dataset, here's what it looks like:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vars.png" style="width: 391px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58854iF1D063C06E107CB9/image-size/large?v=v2&amp;amp;px=999" role="button" title="vars.png" alt="vars.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the simple case, you could create a box plot using code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test7;&lt;BR /&gt;vbox var1;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But the way the data is arranged in the dataset, you can't get the 3 boxplots (for var1, var2, and var3) plotted together using that simple case code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of var1, var2, and var3 being separate variables, you'll want them to be values of a single variable. Here's one way you could re-arrange the data using a simple data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data test7_mod (keep = x value); set test7;&lt;BR /&gt;x='var1'; value=var1; output;&lt;BR /&gt;x='var2'; value=var2; output;&lt;BR /&gt;x='var3'; value=var3; output;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which changes the way the data is structured to this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="vars2.png" style="width: 228px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58855i7B4EF7600EEFFA5A/image-size/large?v=v2&amp;amp;px=999" role="button" title="vars2.png" alt="vars2.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then, you can create a boxplot with the following code, using the group= option (note there are multiple ways to create a box plot in SAS - this is just one of them!)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sgplot data=test7_mod;&lt;BR /&gt;vbox value / group=x;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="box.png" style="width: 640px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58856i808066D5BEF6C28D/image-size/large?v=v2&amp;amp;px=999" role="button" title="box.png" alt="box.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 29 Apr 2021 12:38:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/737880#M21466</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2021-04-29T12:38:56Z</dc:date>
    </item>
    <item>
      <title>Re: Creating boxplots</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/738419#M21471</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="boxplot.png" style="width: 254px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/58932i72284B26B24E08F8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="boxplot.png" alt="boxplot.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;libname test  '~/test';
/* proc print data=test.test7; */
run;
data x;
   set test.test7;
     id=_n_;
 run;
proc transpose data=x out=tran (rename=(_name_=var col1=value) drop=_label_);
  by id;
  var var: ;  
label var='Box Variables';
run; 
proc sgplot data=tran;
title 'SGPLOT';
vbox value / category=var;
/*   replace category with group for different color bars */
run;
proc sgpanel data=tran ;
title 'SGPanel';
  panelby var / COLUMNS=3;
  vbox value;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 02 May 2021 17:52:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Creating-boxplots/m-p/738419#M21471</guid>
      <dc:creator>ghosh</dc:creator>
      <dc:date>2021-05-02T17:52:30Z</dc:date>
    </item>
  </channel>
</rss>

