<?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: Display mean on boxplot with sgpanel in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/672379#M23428</link>
    <description>&lt;P&gt;Mean quantity of what variable? Within group?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example that may help using the SASHELP.Class dataset that plots VBox of weight by age, paneled by sex.&lt;/P&gt;
&lt;P&gt;Basically it involves calculating the mean of whatever and then overlaying a scatter plot to show the value.&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class
   out=work.class;
   by sex;
run;

proc summary data=work.class nway;
   class sex age;
   var weight;
   output out=work.summary(drop=_:) mean=meanweight;
run;

data work.plot;
   set work.class
       work.summary
   ;
run;

proc sgpanel data=work.plot;
   panelby sex;
   vbox weight /category=age group=age ;
   scatter x=age y=meanweight /markerchar=meanweight;
run;&lt;/PRE&gt;
&lt;P&gt;Since the format associated with Meanweight by default is a BEST you may want to specify a format to display fewer decimals.&lt;/P&gt;</description>
    <pubDate>Sun, 26 Jul 2020 07:02:15 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2020-07-26T07:02:15Z</dc:date>
    <item>
      <title>Display mean on boxplot with sgpanel</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/672342#M23425</link>
      <description>&lt;P&gt;I have an sgpanel where I want to show categorical boxplots inside each panel. For these boxplots, I'd like to display the mean quantity. However, I can't find a way to do this. Is it possible? Here's my proc sgpanel, and the result is below. I'd like to display the value for mean on this panel for each of the box.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sgpanel data=new_one;
panelby testtrain;
vbox diff/category=category nooutliers group=category transparency=0.3;
refline 0/axis=Y lineattrs=(colors=black thickness=2);
run;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="hinashah_0-1595703726855.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47670i36C1EF145B339996/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hinashah_0-1595703726855.png" alt="hinashah_0-1595703726855.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Jul 2020 19:04:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/672342#M23425</guid>
      <dc:creator>hinashah</dc:creator>
      <dc:date>2020-07-25T19:04:57Z</dc:date>
    </item>
    <item>
      <title>Re: Display mean on boxplot with sgpanel</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/672379#M23428</link>
      <description>&lt;P&gt;Mean quantity of what variable? Within group?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example that may help using the SASHELP.Class dataset that plots VBox of weight by age, paneled by sex.&lt;/P&gt;
&lt;P&gt;Basically it involves calculating the mean of whatever and then overlaying a scatter plot to show the value.&lt;/P&gt;
&lt;PRE&gt;proc sort data=sashelp.class
   out=work.class;
   by sex;
run;

proc summary data=work.class nway;
   class sex age;
   var weight;
   output out=work.summary(drop=_:) mean=meanweight;
run;

data work.plot;
   set work.class
       work.summary
   ;
run;

proc sgpanel data=work.plot;
   panelby sex;
   vbox weight /category=age group=age ;
   scatter x=age y=meanweight /markerchar=meanweight;
run;&lt;/PRE&gt;
&lt;P&gt;Since the format associated with Meanweight by default is a BEST you may want to specify a format to display fewer decimals.&lt;/P&gt;</description>
      <pubDate>Sun, 26 Jul 2020 07:02:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/672379#M23428</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-07-26T07:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Display mean on boxplot with sgpanel</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/673763#M23504</link>
      <description>&lt;P&gt;Thanks for your reply! I used your suggestion, and changed my code to something like this. I did want the mean to be displayed for the variable diff. Used the datalabel for scatter, and also added a colaxistable.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc summary data=new_one nway;
	class testtrain category;
	var diff;
	output out=new_summary(drop=_:) mean=meandiff;
run;

data for_panel;
	set new_one new_summary;
run;

proc sgpanel data=for_panel;
	panelby testtrain ;
	vbox diff/category=category nooutliers group=category datalabel ;
	scatter x=category y=meandiff / datalabel=meandiff markerattrs=(size=1px);
	rowaxis values= (0 to 150 by 7) grid label='difference';
	refline 0 / axis=Y lineattrs=(color=black thickness=1);
	colaxistable diff /X=category stat=mean label='mean' separator;
	title 'Difference from Ground Truth';
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Here's the result:&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="hinashah_1-1596210054905.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47842i4381294237DE40BE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="hinashah_1-1596210054905.png" alt="hinashah_1-1596210054905.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thanks for your suggestion!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jul 2020 15:41:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Display-mean-on-boxplot-with-sgpanel/m-p/673763#M23504</guid>
      <dc:creator>hinashah</dc:creator>
      <dc:date>2020-07-31T15:41:21Z</dc:date>
    </item>
  </channel>
</rss>

