<?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: Simple way to label your boxplot? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921830#M363005</link>
    <description>&lt;P&gt;Did you try adapting&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s macro to supper grouped data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would think you would add the group to the initial SGPLOT which calculates the statistics.&amp;nbsp; Not sure how the output from that step would change, but the general approach of use SGPLOT to calculate statistics, then combine the calculated statistics with your main data, then you SGPLOT again to generate the box plot and display the calculates statistics via SCATTER should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're doing this for the first time, you might want to do it in 'open code', i.e. outside of a macro definition.&amp;nbsp; That should make it easier to develop and test.&amp;nbsp; Then once the non-macro version is working, if you would benefit from having a general macro, you can write the macro as step 2.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 26 Mar 2024 17:10:54 GMT</pubDate>
    <dc:creator>Quentin</dc:creator>
    <dc:date>2024-03-26T17:10:54Z</dc:date>
    <item>
      <title>Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921750#M362973</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like a simple way to achieve the following boxplot chart with SAS:&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="graphwanted.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94927iFE84838A1CA6769D/image-size/large?v=v2&amp;amp;px=999" role="button" title="graphwanted.png" alt="graphwanted.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;I would like the mean, median, and max shown on the boxplot near the point on the graph. Please let me know if this is possible in a simple way.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;J Fuchsia&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 21:36:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921750#M362973</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-25T21:36:41Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921752#M362974</link>
      <description>&lt;P&gt;Simple? I would say the answer is NO.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want to do some rather detailed programming ... but that's not simple, so I'll stop there.&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 21:42:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921752#M362974</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-25T21:42:02Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921753#M362975</link>
      <description>&lt;P&gt;Thanks for your reply! Just wondering. I am up to the task. What do I need to do?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 21:47:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921753#M362975</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-25T21:47:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921754#M362976</link>
      <description>&lt;P&gt;PROC SGplot&amp;nbsp; with the SGANNO= option.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/p073bl97jzadkmn15lhq58yiy2uh.htm#n15hq4n4n5f79en1gt1nwcn4pg07" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/p073bl97jzadkmn15lhq58yiy2uh.htm#n15hq4n4n5f79en1gt1nwcn4pg07&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Simpler, but not exactly what you asked for is the VBOX option DISPLAYSTATS&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n1waawwbez01ppn15dn9ehmxzihf.htm#n1eufrvegbi4djn1y2k2iu92d896a" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.4/grstatproc/n1waawwbez01ppn15dn9ehmxzihf.htm#n1eufrvegbi4djn1y2k2iu92d896a&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 22:14:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921754#M362976</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-03-25T22:14:01Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921755#M362977</link>
      <description>&lt;P&gt;First you should start with which procedure you intend to use. There are at least 4 different procedures that will draw boxplots excluding some of the analysis procedures.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You also want to clarify which "MAX" you might mean. One of the options for some of the BOXPLOT syntax MAX is for the largest value below the box upper fence.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You may want to consider starting with something like this:&lt;/P&gt;
&lt;PRE&gt;proc sgplot data=sashelp.class;
   vbox height /  category=sex displaystats=(mean median datamax )
   ;
run;&lt;/PRE&gt;
&lt;P&gt;The values of the largest value, mean and median appear below the box with a marker for the Mean in the box and bar across the box for the location of the Median.&amp;nbsp; The order of the DISPLAYSTATS will be in order in the option with the first appearing closest to the Xaxis and the others above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 22:27:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921755#M362977</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-25T22:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921757#M362979</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;The "displaystats" procedure does not give me the same chart. I need the values to be right at the point on the boxplot not along the x axis. I am ready for a more detailed example if needed. Also, I definitely need MAX ("the largest value below the box upper fence")&amp;nbsp; as defined below.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I&amp;nbsp; am using a grouping variable (see below) so "displaystats " will not work, also I am willing to use whichever boxplot procedure is simpler to code. I have several plots to make and will want to reiterate the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;proc sgplot data=sashelp.cars;&lt;BR /&gt;vbox MPG_City / category=type group=origin displaystats=(mean median max )&lt;BR /&gt;;&lt;BR /&gt;run;&lt;/PRE&gt;&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Mar 2024 22:50:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921757#M362979</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-25T22:50:27Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921768#M362981</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.heart(obs=1000);
run;


/***********箱型图***************/
%macro box_plot(dsn=,x=,y=,title=);
ods select none;
ods output sgplot=sgplot1;
proc sgplot data=&amp;amp;dsn.  ;
vbox &amp;amp;y./category=&amp;amp;x. ;
run;
ods select all;

%let dsid=%sysfunc(open(sgplot1));
%let first=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,1))));
%let second=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,2))));
%let third=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,3))));
%let dsid=%sysfunc(close(&amp;amp;dsid));

data temp(rename=(&amp;amp;third.=&amp;amp;x. &amp;amp;first.=_y &amp;amp;second.=_stat));
 set sgplot1;
 _value=round(&amp;amp;first.,0.01);
 if not missing(&amp;amp;second.) and &amp;amp;second. in ('MIN' 'MAX' 'MEDIAN' 'MEAN' 'Q1' 'Q3');
 keep _value &amp;amp;first. &amp;amp;second. &amp;amp;third.;
run;
data want;
 set &amp;amp;dsn. temp;
 if _stat  in ( 'MEDIAN') then _value1=_value;
 if _stat  in ( 'MIN' 'MAX') then _value2=_value;
 if _stat  in ( 'MEAN' ) then _value3=_value;
run;
title  c=black  "&amp;amp;title.";  
proc sgplot data=want noautolegend ;
vbox &amp;amp;y./category=&amp;amp;x. nomean boxwidth=0.1 ;
scatter x=&amp;amp;x. y=_y /discreteoffset=0.15  markerchar=_value1 labelstrip  markercharattrs=(size=8) ;
scatter x=&amp;amp;x. y=_y /discreteoffset=0.15  markerchar=_value2 labelstrip  markercharattrs=(size=8) ;
scatter x=&amp;amp;x. y=_y /discreteoffset=0.15  markerchar=_value3 labelstrip  markercharattrs=(size=8)  ;

scatter x=&amp;amp;x. y=_value3 /markerattrs=(color=darkred symbol=circlefilled) name='mean' legendlabel='Mean';
scatter x=&amp;amp;x. y=_value1 /markerattrs=(color=navy symbol=diamondfilled) name='median' legendlabel='Median';

yaxis integer;
keylegend 'mean' 'median'/AUTOITEMSIZE;
run;
title;
%mend;

%box_plot(dsn=have,x=bp_status,y=weight, title=VCSS-Socre)


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_1-1711419447921.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94929i0F4DFB987A953B6A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1711419447921.png" alt="Ksharp_1-1711419447921.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 02:17:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921768#M362981</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-03-26T02:17:35Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921803#M362994</link>
      <description>&lt;P&gt;This is just what I need. But how do I make it work for data that is grouped (by year)?&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:06:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921803#M362994</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T15:06:42Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921806#M362997</link>
      <description>&lt;P&gt;Also, I would like to account for scale in my data.&lt;/P&gt;
&lt;P&gt;Something like,&amp;nbsp; "where 0 &amp;lt;= &amp;amp;y. &amp;lt;=500;" is not working correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:21:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921806#M362997</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T15:21:34Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921810#M362999</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/463731"&gt;@JFuchsia&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Also, I would like to account for scale in my data.&lt;/P&gt;
&lt;P&gt;Something like,&amp;nbsp; "where 0 &amp;lt;= &amp;amp;y. &amp;lt;=500;" is not working correctly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;"Not working correctly" is awful vague.&lt;BR /&gt;&lt;BR /&gt;Are there errors in the log?: Post the code and log in a code box opened with the "&amp;lt;&amp;gt;" to maintain formatting of error messages.&lt;BR /&gt;&lt;BR /&gt;No output? Post any log in a code box.&lt;BR /&gt;&lt;BR /&gt;Unexpected output? Provide input data in the form of data step code pasted into a code box, the actual results and the expected results. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the "&amp;lt;/&amp;gt;" icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:36:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921810#M362999</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-26T15:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921812#M363000</link>
      <description>&lt;P&gt;When I try to use the&amp;nbsp;&amp;nbsp; "Where 0 &amp;lt;= &amp;amp;y. &amp;lt;=500;" with the anywhere in the SGPLOT procedure statement then all of my annotation disappears on the subsequent plot.&lt;/P&gt;
&lt;P&gt;When I try to use the grouping variable (year, in my case) I get the plot but without annotation, and the following statement in the log:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;WARNING: Y=_Y is invalid. The option expects that the column not contain all missing values.
WARNING: Y=_Y is invalid. The option expects that the column not contain all missing values.
WARNING: Y=_Y is invalid. The option expects that the column not contain all missing values.
WARNING: Y=_VALUE3 is invalid. The option expects that the column not contain all missing values.
WARNING: Y=_VALUE1 is invalid. The option expects that the column not contain all missing values
&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921812#M363000</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T15:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921814#M363001</link>
      <description>&lt;P&gt;I tweaked the&amp;nbsp; previous scale statement in the current code to this :&lt;/P&gt;
&lt;PRE&gt;yaxis integer values=(0 to 500 by 10);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and the scale is much better and I don't lose my plot labels (for mean, min, etc.)&lt;/P&gt;
&lt;P&gt;however, how can I group the data by each year?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 15:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921814#M363001</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T15:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921830#M363005</link>
      <description>&lt;P&gt;Did you try adapting&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;'s macro to supper grouped data?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would think you would add the group to the initial SGPLOT which calculates the statistics.&amp;nbsp; Not sure how the output from that step would change, but the general approach of use SGPLOT to calculate statistics, then combine the calculated statistics with your main data, then you SGPLOT again to generate the box plot and display the calculates statistics via SCATTER should work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you're doing this for the first time, you might want to do it in 'open code', i.e. outside of a macro definition.&amp;nbsp; That should make it easier to develop and test.&amp;nbsp; Then once the non-macro version is working, if you would benefit from having a general macro, you can write the macro as step 2.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 17:10:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921830#M363005</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-03-26T17:10:54Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921832#M363006</link>
      <description>&lt;P&gt;I did adapt the Macro, the only issue now is that the scatter plot portions are off since the data is now grouped as well as categorized.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The scatter plot of the stats data is all along one axis, it's correct&amp;nbsp; but I need it to group along the bar that it belongs to within the group. A snapshot is coming.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 17:26:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921832#M363006</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T17:26:38Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921833#M363007</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/463731"&gt;@JFuchsia&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I tweaked the&amp;nbsp; previous scale statement in the current code to this :&lt;/P&gt;
&lt;PRE&gt;yaxis integer values=(0 to 500 by 10);&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;and the scale is much better and I don't lose my plot labels (for mean, min, etc.)&lt;/P&gt;
&lt;P&gt;however, how can I group the data by each year?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Not exactly clear what sort of "group" you are looking for. The Group=variable option on the plot? But since we don't know&amp;nbsp; your data or even the actual code you are running can't tell.&lt;/P&gt;
&lt;P&gt;A separate graph for each year? That might be a BY statement. Or SGPANEL and PANELBY your year variable.&lt;/P&gt;
&lt;P&gt;Or overlay multiple plots using different data layout.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 17:27:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921833#M363007</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-03-26T17:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921837#M363009</link>
      <description>&lt;P&gt;So,&lt;/P&gt;
&lt;P&gt;when I add group= sex, I get the following code:&lt;/P&gt;
&lt;PRE&gt;data have;
 set sashelp.heart(obs=1000);
run;&lt;BR /&gt;
%macro box_plot(dsn=,x=,y=,title=);
ods select none;
ods output sgplot=sgplot1;
proc sgplot data=&amp;amp;dsn.  ;
vbox &amp;amp;y./group=sex category=&amp;amp;x. ;
run;
ods select all;

%let dsid=%sysfunc(open(sgplot1));
%let first=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,1))));
%let second=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,2))));
%let third=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,3))));
%let dsid=%sysfunc(close(&amp;amp;dsid));

data temp(rename=(&amp;amp;third.=&amp;amp;x. &amp;amp;first.=_y &amp;amp;second.=_stat));
 set sgplot1;
 _value=round(&amp;amp;first.,0.01);
 if not missing(&amp;amp;second.) and &amp;amp;second. in ('MIN' 'MAX' 'MEDIAN' 'MEAN' 'Q1' 'Q3');
 keep _value &amp;amp;first. &amp;amp;second. &amp;amp;third.;
run;
data want;
 set &amp;amp;dsn. temp;
 if _stat  in ( 'MEDIAN') then _value1=_value;
 if _stat  in ( 'MIN' 'MAX') then _value2=_value;
 if _stat  in ( 'MEAN' ) then _value3=_value;
run;
title  c=black  "&amp;amp;title.";  
proc sgplot data=want noautolegend ;
vbox &amp;amp;y./group=sex category=&amp;amp;x. nomean boxwidth=0.1 ;
scatter x=&amp;amp;x. y=_y /discreteoffset=0.15  markerchar=_value1 labelstrip  markercharattrs=(size=8) ;
scatter x=&amp;amp;x. y=_y /discreteoffset=0.15  markerchar=_value2 labelstrip  markercharattrs=(size=8) ;
scatter x=&amp;amp;x. y=_y /discreteoffset=0.15  markerchar=_value3 labelstrip  markercharattrs=(size=8)  ;

scatter x=&amp;amp;x. y=_value3 /markerattrs=(color=darkred symbol=circlefilled) name='mean' legendlabel='Mean';
scatter x=&amp;amp;x. y=_value1 /markerattrs=(color=navy symbol=diamondfilled) name='median' legendlabel='Median';

yaxis integer;
keylegend 'mean' 'median'/AUTOITEMSIZE;
run;
title;
%mend;

%box_plot(dsn=have,x=bp_status,y=weight, title=VCSS-Socre)&lt;/PRE&gt;
&lt;P&gt;The following plot results:&amp;nbsp;&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="messyplot.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94949i2396743922AFC6CF/image-size/large?v=v2&amp;amp;px=999" role="button" title="messyplot.png" alt="messyplot.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HOW can I fix the plot so that the numbers align appropriately. Sorry for the confusion.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!!! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 17:36:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921837#M363009</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T17:36:28Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921838#M363010</link>
      <description>&lt;P&gt;See new post. Thank you! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 17:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921838#M363010</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T17:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921841#M363011</link>
      <description>&lt;P&gt;I think you need to keep the variable SEX in work.temp, and add group=sex to your scatter plots.&amp;nbsp; I also added groupdisplay=cluster and clusterwidth.&amp;nbsp; This is not working, but I would play with code like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 set sashelp.heart(obs=1000);
run;

ods select none;
ods output sgplot=sgplot1;
proc sgplot data=have  ;
vbox weight/group=sex category=bp_status ;
run;
ods select all;

%let dsid=%sysfunc(open(sgplot1));
%let first=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,1))));
%let second=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,2))));
%let third=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,3))));
%let dsid=%sysfunc(close(&amp;amp;dsid));



data temp(rename=(&amp;amp;third.=bp_status &amp;amp;first.=_y &amp;amp;second.=_stat));
 set sgplot1;
 _value=round(&amp;amp;first.,0.01);
 if not missing(&amp;amp;second.) and &amp;amp;second. in ('MIN' 'MAX' 'MEDIAN' 'MEAN' 'Q1' 'Q3');
 keep _value &amp;amp;first. &amp;amp;second. &amp;amp;third. sex;
run;
data want;
 set have temp;
 if _stat  in ( 'MEDIAN') then _value1=_value;
 if _stat  in ( 'MIN' 'MAX') then _value2=_value;
 if _stat  in ( 'MEAN' ) then _value3=_value;
run;
title  c=black  "foo";  
proc sgplot data=want noautolegend ;
vbox weight/group=sex category=bp_status nomean boxwidth=0.1  groupdisplay=cluster clusterwidth=.8;
scatter x=bp_status y=_y /markerchar=_value1 labelstrip  markercharattrs=(size=8) group=sex groupdisplay=cluster clusterwidth=.8;
scatter x=bp_status y=_y /markerchar=_value2 labelstrip  markercharattrs=(size=8) group=sex groupdisplay=cluster clusterwidth=.8;
scatter x=bp_status y=_y /markerchar=_value3 labelstrip  markercharattrs=(size=8) group=sex groupdisplay=cluster clusterwidth=.8;

scatter x=bp_status y=_value3 /markerattrs=(color=darkred symbol=circlefilled) name='mean' legendlabel='Mean' group=sex  groupdisplay=cluster clusterwidth=.8;
scatter x=bp_status y=_value1 /markerattrs=(color=navy symbol=diamondfilled) name='median' legendlabel='Median' group=sex  groupdisplay=cluster clusterwidth=.8;

yaxis integer;
keylegend 'mean' 'median'/AUTOITEMSIZE;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Mar 2024 18:11:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921841#M363011</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2024-03-26T18:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921846#M363013</link>
      <description>&lt;P&gt;Thank you, this was certainly worth a shot! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 18:34:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921846#M363013</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T18:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Simple way to label your boxplot?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921856#M363018</link>
      <description>&lt;P&gt;So,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I've decided to go with SGPANEL and have given up on SGPLOT and got the following code going:&lt;/P&gt;
&lt;PRE&gt;data have;
 set sashelp.heart(obs=1000);
run;

%macro box_plot(dsn=,x=,y=,title=);
ods select none;
ods output sgpanel=sgplot2;
proc sgpanel data=&amp;amp;dsn.;
panelby bp_status;
vbox &amp;amp;y./  category=&amp;amp;x. ;
run;
ods select all;

%let dsid=%sysfunc(open(sgplot2));
%let first=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,1))));
%let second=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,2))));
%let third=%sysfunc(nliteral(%sysfunc(varname(&amp;amp;dsid,3))));
%let dsid=%sysfunc(close(&amp;amp;dsid));

data temp(rename=(&amp;amp;third.=&amp;amp;x. &amp;amp;first.=_y &amp;amp;second.=_stat));
 set sgplot2;
 _value=round(&amp;amp;first.,0.01);
 if not missing(&amp;amp;second.) and &amp;amp;second. in ('MIN' 'MAX' 'MEDIAN' 'MEAN' 'Q1' 'Q3');
 keep _value &amp;amp;first. &amp;amp;second. &amp;amp;third. bp_status;
run;
data want;
 set &amp;amp;dsn. temp;
 if _stat  in ( 'MEDIAN') then _value1=_value;
 if _stat  in ( 'MIN') then _value2=_value;
 if _stat  in ('MAX') then _value3=_value;
 if _stat  in ( 'MEAN' ) then _value4=_value;
run;
title  c=black  "&amp;amp;title.";  
proc sgpanel data=want noautolegend ;
panelby bp_status;
vbox &amp;amp;y./category=&amp;amp;x. nomean boxwidth=0.2;

scatter x=&amp;amp;x. y=_y / discreteoffset=0.2  markerchar=_value1 labelstrip  markercharattrs=(size=8);
scatter x=&amp;amp;x. y=_y /discreteoffset=0.2  markerchar=_value2 labelstrip  markercharattrs=(size=8);
scatter x=&amp;amp;x. y=_y /discreteoffset=0.2  markerchar=_value3 labelstrip  markercharattrs=(size=8);
scatter x=&amp;amp;x. y=_y /discreteoffset=0.2  markerchar=_value4 labelstrip  markercharattrs=(size=8);

scatter x=&amp;amp;x. y=_value4 /markerattrs=(color=darkred symbol=circlefilled) name='mean' legendlabel='Mean' ;
scatter x=&amp;amp;x. y=_value1 /markerattrs=(color=navy symbol=diamondfilled) name='median' legendlabel='Median' ;

keylegend 'mean' 'median'/AUTOITEMSIZE;
run;
title;
%mend;

%box_plot(dsn=have, x=sex, y=weight, title=VCSS-Score)&lt;/PRE&gt;
&lt;P&gt;I greatly dislike the way the panel's output in this one as it's hard to tell what the scale is all the time:&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="latticedata.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/94954iF02DDA18590D6A1A/image-size/large?v=v2&amp;amp;px=999" role="button" title="latticedata.png" alt="latticedata.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I would like everything in one panel but what can I do??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;J Fuchsia&lt;/P&gt;</description>
      <pubDate>Tue, 26 Mar 2024 19:46:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Simple-way-to-label-your-boxplot/m-p/921856#M363018</guid>
      <dc:creator>JFuchsia</dc:creator>
      <dc:date>2024-03-26T19:46:05Z</dc:date>
    </item>
  </channel>
</rss>

