<?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 Adding a reference band to proc boxplot graph in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566089#M18294</link>
    <description>&lt;P&gt;I am wondering how best to add a reference 'band' to a proc boxplot graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been able to add reflines (vref=) at the lower and upper limits but cannot change color (cvref) while using ods graphics. Here is the code and output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc boxplot data=work.living ;
	by housing ;
	where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
	plot bcs*dow / 
			boxstyle=schematicid
			vaxis=1 to 5 by 1 
			grid
			vref=2.333 3.667 
		;
	id db108;
	insetgroup min max mean n ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV class="c"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Boxplot210.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30274i30E5C913968F4EBF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Boxplot210.png" alt="Boxplot210.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;But I'd rather use a lightly colored (transparent) band that indicates the reference range. I think I should be able to do this using an annotation data set (annoref) that defines a rectangle. But I seem to get nothing on the graph and nothing in the log to indicate why. Here is my current code, resulting graph and log for everything.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.annoref;
retain	drawspace "WALLPERCENT" ;
length function $9 ;
input function $ height width x1 y1 ;
datalines;
rectangle	10	70	10	50	
;
run;

proc print data=work.annoref ; run;

proc boxplot data=work.living ;
	by housing ;
	where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
	plot bcs*dow / 
			boxstyle=schematicid
			vaxis=1 to 5 by 1 
			grid
			annotate=work.annoref 
		;
	id db108;
	insetgroup min max mean n ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Boxplot214.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30275iCB7B0D44D4189206/image-size/large?v=v2&amp;amp;px=999" role="button" title="Boxplot214.png" alt="Boxplot214.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;791  title; title2; footnote;
792  proc boxplot data=work.living ;
793      by housing ;
794      where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
795      plot bcs*dow /
796              boxstyle=schematicid
797              vaxis=1 to 5 by 1
798              grid
799              vref=2.333 3.667
800          ;
801      id db108;
802      insetgroup min max mean n ;
803  run;

NOTE: Writing HTML Body file: sashtml2.htm
NOTE: Processing beginning for PLOT statement number 1.
NOTE: Processing started for the BY group housing=CF-2.
NOTE: Since the format DATE is associated with the group variable dow, it is assumed that the
      natural interval between group positions is one DAY.
NOTE: The REPEAT option is assumed when a DATE format is used with a group variable.
NOTE: The above message was for the following BY group:
      housing=CF-2
NOTE: There were 196 observations read from the data set WORK.LIVING.
      WHERE (dow&amp;gt;'01NOV2018'D) and (age_today&amp;gt;=6) and (housing='CF-2');
NOTE: PROCEDURE BOXPLOT used (Total process time):
      real time           1.34 seconds
      cpu time            0.18 seconds


804
805  data work.annoref;
806  retain  drawspace "WALLPERCENT" ;
807  length function $9 ;
808  input function $ height width x1 y1 ;
809  datalines;

NOTE: The data set WORK.ANNOREF has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


811  ;
812  run;
813
814  proc print data=work.annoref ; run;

NOTE: There were 1 observations read from the data set WORK.ANNOREF.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.23 seconds
      cpu time            0.03 seconds


815
816  proc boxplot data=work.living ;
817      by housing ;
818      where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
819      plot bcs*dow /
820              boxstyle=schematicid
821              vaxis=1 to 5 by 1
822              grid
823              annotate=work.annoref
824          ;
825      id db108;
826      insetgroup min max mean n ;
827  run;

NOTE: Processing beginning for PLOT statement number 1.
NOTE: Processing started for the BY group housing=CF-2.
NOTE: Since the format DATE is associated with the group variable dow, it is assumed that the
      natural interval between group positions is one DAY.
NOTE: The REPEAT option is assumed when a DATE format is used with a group variable.
NOTE: The above message was for the following BY group:
      housing=CF-2
NOTE: There were 196 observations read from the data set WORK.LIVING.
      WHERE (dow&amp;gt;'01NOV2018'D) and (age_today&amp;gt;=6) and (housing='CF-2');
NOTE: PROCEDURE BOXPLOT used (Total process time):
      real time           0.62 seconds
      cpu time            0.10 seconds


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I know I'm going to have to set the rectangle dimensions better, but I wanted just to see something before I tried to figure that part out next.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Dave&lt;/P&gt;</description>
    <pubDate>Thu, 13 Jun 2019 23:42:55 GMT</pubDate>
    <dc:creator>das</dc:creator>
    <dc:date>2019-06-13T23:42:55Z</dc:date>
    <item>
      <title>Adding a reference band to proc boxplot graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566089#M18294</link>
      <description>&lt;P&gt;I am wondering how best to add a reference 'band' to a proc boxplot graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have been able to add reflines (vref=) at the lower and upper limits but cannot change color (cvref) while using ods graphics. Here is the code and output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc boxplot data=work.living ;
	by housing ;
	where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
	plot bcs*dow / 
			boxstyle=schematicid
			vaxis=1 to 5 by 1 
			grid
			vref=2.333 3.667 
		;
	id db108;
	insetgroup min max mean n ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;DIV class="branch"&gt;
&lt;DIV&gt;
&lt;DIV class="c"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Boxplot210.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30274i30E5C913968F4EBF/image-size/large?v=v2&amp;amp;px=999" role="button" title="Boxplot210.png" alt="Boxplot210.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;But I'd rather use a lightly colored (transparent) band that indicates the reference range. I think I should be able to do this using an annotation data set (annoref) that defines a rectangle. But I seem to get nothing on the graph and nothing in the log to indicate why. Here is my current code, resulting graph and log for everything.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.annoref;
retain	drawspace "WALLPERCENT" ;
length function $9 ;
input function $ height width x1 y1 ;
datalines;
rectangle	10	70	10	50	
;
run;

proc print data=work.annoref ; run;

proc boxplot data=work.living ;
	by housing ;
	where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
	plot bcs*dow / 
			boxstyle=schematicid
			vaxis=1 to 5 by 1 
			grid
			annotate=work.annoref 
		;
	id db108;
	insetgroup min max mean n ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Boxplot214.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30275iCB7B0D44D4189206/image-size/large?v=v2&amp;amp;px=999" role="button" title="Boxplot214.png" alt="Boxplot214.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;791  title; title2; footnote;
792  proc boxplot data=work.living ;
793      by housing ;
794      where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
795      plot bcs*dow /
796              boxstyle=schematicid
797              vaxis=1 to 5 by 1
798              grid
799              vref=2.333 3.667
800          ;
801      id db108;
802      insetgroup min max mean n ;
803  run;

NOTE: Writing HTML Body file: sashtml2.htm
NOTE: Processing beginning for PLOT statement number 1.
NOTE: Processing started for the BY group housing=CF-2.
NOTE: Since the format DATE is associated with the group variable dow, it is assumed that the
      natural interval between group positions is one DAY.
NOTE: The REPEAT option is assumed when a DATE format is used with a group variable.
NOTE: The above message was for the following BY group:
      housing=CF-2
NOTE: There were 196 observations read from the data set WORK.LIVING.
      WHERE (dow&amp;gt;'01NOV2018'D) and (age_today&amp;gt;=6) and (housing='CF-2');
NOTE: PROCEDURE BOXPLOT used (Total process time):
      real time           1.34 seconds
      cpu time            0.18 seconds


804
805  data work.annoref;
806  retain  drawspace "WALLPERCENT" ;
807  length function $9 ;
808  input function $ height width x1 y1 ;
809  datalines;

NOTE: The data set WORK.ANNOREF has 1 observations and 6 variables.
NOTE: DATA statement used (Total process time):
      real time           0.03 seconds
      cpu time            0.03 seconds


811  ;
812  run;
813
814  proc print data=work.annoref ; run;

NOTE: There were 1 observations read from the data set WORK.ANNOREF.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.23 seconds
      cpu time            0.03 seconds


815
816  proc boxplot data=work.living ;
817      by housing ;
818      where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6 and housing="CF-2";
819      plot bcs*dow /
820              boxstyle=schematicid
821              vaxis=1 to 5 by 1
822              grid
823              annotate=work.annoref
824          ;
825      id db108;
826      insetgroup min max mean n ;
827  run;

NOTE: Processing beginning for PLOT statement number 1.
NOTE: Processing started for the BY group housing=CF-2.
NOTE: Since the format DATE is associated with the group variable dow, it is assumed that the
      natural interval between group positions is one DAY.
NOTE: The REPEAT option is assumed when a DATE format is used with a group variable.
NOTE: The above message was for the following BY group:
      housing=CF-2
NOTE: There were 196 observations read from the data set WORK.LIVING.
      WHERE (dow&amp;gt;'01NOV2018'D) and (age_today&amp;gt;=6) and (housing='CF-2');
NOTE: PROCEDURE BOXPLOT used (Total process time):
      real time           0.62 seconds
      cpu time            0.10 seconds


&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I know I'm going to have to set the rectangle dimensions better, but I wanted just to see something before I tried to figure that part out next.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you,&lt;/P&gt;
&lt;P&gt;Dave&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2019 23:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566089#M18294</guid>
      <dc:creator>das</dc:creator>
      <dc:date>2019-06-13T23:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a reference band to proc boxplot graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566251#M18296</link>
      <description>&lt;P&gt;I'm not sure of your SAS version, but this is something you can do in SGPLOT:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.heart;
  band x=sex upper=230 lower=180 / name="conf" legendlabel="confidence region";
  vbox cholesterol / category=sex displaystats=(min max mean n);
  keylegend "conf";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Give that a try and see if it works for you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;BR /&gt;Dan&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jun 2019 18:00:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566251#M18296</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2019-06-14T18:00:51Z</dc:date>
    </item>
    <item>
      <title>Re: Adding a reference band to proc boxplot graph</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566644#M18311</link>
      <description>&lt;P&gt;Thank you DanH_sas. That works nicely in 9.4. Here is my code and example figure. I like it a lot.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=work.living ;
	by housing ;
	where dow&amp;gt;'01NOV2018'd and age_today&amp;gt;=6;
	band x=dow upper=3.667 lower=2.333 / name="nr" legendlabel="normal range";
	vbox bcs / category=dow displaystats=(min max mean n);
	xaxis type=time display=(nolabel);
	yaxis values=(1 to 5 by 1) grid ;
	keylegend "nr";
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SGPlot33.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30333iA55BEA8E6B2C07CD/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPlot33.png" alt="SGPlot33.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2019 17:07:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Adding-a-reference-band-to-proc-boxplot-graph/m-p/566644#M18311</guid>
      <dc:creator>das</dc:creator>
      <dc:date>2019-06-17T17:07:11Z</dc:date>
    </item>
  </channel>
</rss>

