<?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: BOX Plot customization using Proc Template in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955161#M25217</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; is this possible the x-axis table can we group together and present it once? These numbers will be same all the time.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1736109460892.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103485iBAD7ADD9EF234A19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1736109460892.png" alt="SASuserlot_0-1736109460892.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 05 Jan 2025 20:37:55 GMT</pubDate>
    <dc:creator>SASuserlot</dc:creator>
    <dc:date>2025-01-05T20:37:55Z</dc:date>
    <item>
      <title>BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954614#M25201</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;
&lt;P&gt;I was able to create a box plot, But I am not getting quite what I want. I am providing the code, and customization I am looking in image. Out of 3 customization one I am not sure How I can achieve it ( making the numbers horizontal) . Making the color change I am not sure where I am doing wrong, Tried multiple attempts but not working for some reason. Your inputs and ideas greatly appreciated.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1735169025705.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103370iBDAE7B39AD67A2E6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1735169025705.png" alt="SASuserlot_0-1735169025705.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;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;


proc sort data=dummy_data; 
by trtn agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by trtn agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n;
run;
data final;
	merge dummy_data stat(drop=_:);
	by trtn agegrpn; 
	num =1;
run;


proc template;
    define statgraph boxplot;

    begingraph / datacolors=(lightblue lightgreen  lightgrey) datasymbols=(trianglefilled squarefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=0.12 offsetmax=0.12 label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        boxplot x=agegrpn y=AVAL / group=trtn groupdisplay=cluster boxwidth=0.56 clusterwidth=0.53 
            medianattrs=(color=black thickness=2px);

        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=trtn  classorder=ascending 
                valueattrs=(weight=bold) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\Users\xx\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 25 Dec 2024 23:41:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954614#M25201</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-12-25T23:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954618#M25202</link>
      <description>&lt;PRE&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;


proc sort data=dummy_data; 
by trtn agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by trtn agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n mean=mean;
run;
data final;
	merge dummy_data stat(drop=_:);
	by trtn agegrpn; 
	num =1;
&lt;STRONG&gt;if TREATMENT='DrugA' then mean1=mean;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if TREATMENT='DrugB' then mean2=mean;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;if TREATMENT='Refer' then mean3=mean;&lt;/STRONG&gt;&lt;BR /&gt;

run;


proc template;
    define statgraph boxplot;

    begingraph / datacolors=(lightblue lightgreen  lightgrey) &lt;STRONG&gt;datacontrastcolors=(lightblue lightgreen  lightgrey)&lt;/STRONG&gt; 
datasymbols=(trianglefilled squarefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=0.12 offsetmax=0.12 label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        boxplot x=agegrpn y=AVAL / group=trtn groupdisplay=cluster boxwidth=0.56 clusterwidth=0.53 
            medianattrs=(color=black thickness=2px);

      &lt;STRONG&gt;  /*scatter of mean*/
	   scatterplot x=agegrpn y=mean1/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=trianglefilled color=blue);
	   scatterplot x=agegrpn y=mean2/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=squarefilled color=green);
	   scatterplot x=agegrpn y=mean3/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=circlefilled color=grey);
&lt;/STRONG&gt;

        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=trtn &lt;STRONG&gt; classdisplay=cluster&lt;/STRONG&gt; &lt;STRONG&gt;clusterwidth=0.53&lt;/STRONG&gt; classorder=ascending 
                valueattrs=(weight=bold) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1735180581801.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103373i42CD410A5E561A0F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1735180581801.png" alt="Ksharp_0-1735180581801.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2024 02:36:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954618#M25202</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-26T02:36:27Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954624#M25203</link>
      <description>&lt;P&gt;Perfect. Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;. You were awesome.&lt;/P&gt;
&lt;P&gt;Two questions:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's the reason are you using the Mean instead of the Median?&lt;/P&gt;
&lt;P&gt;Can we make the median line in each box match the legend? Like in this blue-filled triangle with a blue line instead of the black line.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1735181657948.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103374iD4990E2A2018C821/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1735181657948.png" alt="SASuserlot_0-1735181657948.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2024 02:54:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954624#M25203</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-12-26T02:54:28Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954626#M25204</link>
      <description>&lt;P&gt;"What's the reason are you using the Mean instead of the Median?"&lt;/P&gt;
&lt;P&gt;That&amp;nbsp;&lt;SPAN&gt;blue-filled triangle stands for Mean, not Median, that is reason why I used Mean.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;"Can we make the median line in each box match the legend?"&lt;/P&gt;
&lt;P&gt;Sure.Check this:&lt;/P&gt;
&lt;PRE&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;


proc sort data=dummy_data; 
by trtn agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by trtn agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n mean=mean median=median;
run;
data final;
	merge dummy_data stat(drop=_:);
	by trtn agegrpn; 
	num =1;
&lt;STRONG&gt;if TREATMENT='DrugA' then do;mean1=mean;median1=median;end;
if TREATMENT='DrugB' then do;mean2=mean;median2=median;end;
if TREATMENT='Refer' then do;mean3=mean;median3=median;end;
&lt;/STRONG&gt;
run;


proc template;
    define statgraph boxplot;

    begingraph / datacolors=(lightblue lightgreen  lightgrey) datacontrastcolors=(lightblue lightgreen  lightgrey) 
datasymbols=(trianglefilled squarefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=0.12 offsetmax=0.12 label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        &lt;STRONG&gt;boxplot x=agegrpn y=AVAL / group=trtn groupdisplay=cluster boxwidth=0.56 clusterwidth=0.53  ;&lt;/STRONG&gt;

        /*scatter of mean*/
	   scatterplot x=agegrpn y=mean1/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=trianglefilled color=blue);
	   scatterplot x=agegrpn y=mean2/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=squarefilled color=green);
	   scatterplot x=agegrpn y=mean3/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=circlefilled color=grey);

        /*scatter of median*/
	 &lt;STRONG&gt;  highlowplot x=agegrpn low=median1 high=median1/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=blue) ;
	   highlowplot x=agegrpn low=median2 high=median2/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=green) ;
	   highlowplot x=agegrpn low=median3 high=median3/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=grey) ;
&lt;/STRONG&gt;
        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=trtn  classdisplay=cluster clusterwidth=0.53 classorder=ascending 
                valueattrs=(weight=bold) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1735182932668.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103375i86BAC7C713A5DDE9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1735182932668.png" alt="Ksharp_0-1735182932668.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2024 03:17:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954626#M25204</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2024-12-26T03:17:17Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954646#M25205</link>
      <description>&lt;P&gt;Perfect. It worked like Gem Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2024 15:54:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/954646#M25205</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2024-12-26T15:54:49Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955115#M25211</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, I have a question on this figure; when you get a chance, can you please let me know? &amp;nbsp; The code I provided generated the results for the Year 2009, and it exactly produced the same results in 2010&amp;nbsp; with everything same data. Is it possible to show 6 bars in each group side by side with 2009 and 2010 results to compare in one figure? example in&amp;nbsp; for one Group&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1736029140568.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103479i6F0EA5AF86E0E1A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1736029140568.png" alt="SASuserlot_0-1736029140568.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 04 Jan 2025 22:19:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955115#M25211</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-04T22:19:34Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955122#M25212</link>
      <description>&lt;P&gt;Sure. Post your dataset ,so can test code.&lt;/P&gt;
&lt;P&gt;In your original dummy dataset ,there are not YEAR variable.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;OK . Using the data you posted for example:&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;

data dummy_data;
length treatment _treatment $ 40;
    set dummy_data;
   _treatment=treatment;
	treatment=cats(_treatment,'2019');
    output; 

    /* Modify for Year 2010 */
    Year = 2010;
    AVAL = AVAL + 1000;
	treatment=cats(_treatment,'2020');
    output; 
run;

proc sort data=dummy_data; 
by treatment agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by treatment agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n mean=mean median=median;
run;
data final;
	merge dummy_data stat(drop=_:);
	by treatment agegrpn; 
	num =1;
if TREATMENT='DrugA2019' then do;mean1=mean;median1=median;end;
if TREATMENT='DrugA2020' then do;mean11=mean;median11=median;end;

if TREATMENT='DrugB2019' then do;mean2=mean;median2=median;end;
if TREATMENT='DrugB2020' then do;mean22=mean;median22=median;end;

if TREATMENT='Refer2019' then do;mean3=mean;median3=median;end;
if TREATMENT='Refer2020' then do;mean33=mean;median33=median;end;

run;

proc sort data=final;by treatment;run;


proc template;
    define statgraph boxplot;

    begingraph /
datacolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey)
datacontrastcolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey) 
datasymbols=(trianglefilled trianglefilled squarefilled squarefilled circlefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=0.12 offsetmax=0.12 label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        boxplot x=agegrpn y=AVAL / group=treatment groupdisplay=cluster boxwidth=0.56 clusterwidth=0.53  ;

        /*scatter of mean*/
	   scatterplot x=agegrpn y=mean1/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=trianglefilled color=blue);
	   scatterplot x=agegrpn y=mean11/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=trianglefilled color=blue);

	   scatterplot x=agegrpn y=mean2/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=squarefilled color=green);
	   scatterplot x=agegrpn y=mean22/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=squarefilled color=green);

       scatterplot x=agegrpn y=mean3/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=circlefilled color=grey);
       scatterplot x=agegrpn y=mean33/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=circlefilled color=grey);

        /*scatter of median*/
	   highlowplot x=agegrpn low=median1 high=median1/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=blue) ;
	   highlowplot x=agegrpn low=median11 high=median11/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=blue) ;

       highlowplot x=agegrpn low=median2 high=median2/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=green) ;
       highlowplot x=agegrpn low=median22 high=median22/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=green) ;

       highlowplot x=agegrpn low=median3 high=median3/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=grey) ;
       highlowplot x=agegrpn low=median33 high=median33/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=grey) ;

        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=treatment  classdisplay=cluster clusterwidth=0.53 classorder=ascending 
                valueattrs=(weight=bold size=12) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1736043107848.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103482i2ED82C1178CB2959/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1736043107848.png" alt="Ksharp_0-1736043107848.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 02:11:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955122#M25212</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-05T02:11:54Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955123#M25213</link>
      <description>&lt;P&gt;Thanks for your Response. I created the Dummy data with Year and Increased the AVAL for the 2010 Year.&amp;nbsp; The rest of the Proc Template code is already there in the previous post. If you need anything else please let me know.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    /* Year for original data */
    Year = 2009;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;

data dummy_data_final;
    set dummy_data;
    output; 

    /* Modify for Year 2010 */
    Year = 2010;
    AVAL = AVAL + 1000;
    output; 
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 05 Jan 2025 01:37:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955123#M25213</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-05T01:37:40Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955127#M25215</link>
      <description>&lt;P&gt;Perfect. Thank you.&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":folded_hands:"&gt;🙏&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 02:15:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955127#M25215</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-05T02:15:05Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955128#M25216</link>
      <description>&lt;P&gt;&lt;STRONG&gt;My post above has been updated.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 02:15:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955128#M25216</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-05T02:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955161#M25217</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp; is this possible the x-axis table can we group together and present it once? These numbers will be same all the time.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1736109460892.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103485iBAD7ADD9EF234A19/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1736109460892.png" alt="SASuserlot_0-1736109460892.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 05 Jan 2025 20:37:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955161#M25217</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-05T20:37:55Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955168#M25218</link>
      <description>&lt;P&gt;Sure. Of course.&lt;/P&gt;
&lt;PRE&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;

data dummy_data;
length treatment _treatment $ 40;
    set dummy_data;
   _treatment=treatment;
	treatment=cats(_treatment,'2019');
    output; 

    /* Modify for Year 2010 */
    Year = 2010;
    AVAL = AVAL + 1000;
	treatment=cats(_treatment,'2020');
    output; 
run;

proc sort data=dummy_data; 
by treatment agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by treatment agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n mean=mean median=median;
run;
data final;
	merge dummy_data stat(drop=_:);
	by treatment agegrpn; 
	num =1;
if TREATMENT=:'DrugA' then do;mean1=mean;median1=median;end;
if TREATMENT=:'DrugB' then do;mean2=mean;median2=median;end;
if TREATMENT=:'Refer' then do;mean3=mean;median3=median;end;
run;

proc sort data=final;by treatment;run;


proc template;
    define statgraph boxplot;

    begingraph /
datacolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey)
datacontrastcolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey) 
datasymbols=(trianglefilled trianglefilled squarefilled squarefilled circlefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=0.12 offsetmax=0.12 label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        boxplot x=agegrpn y=AVAL / group=treatment groupdisplay=cluster boxwidth=0.56 clusterwidth=0.53  ;

        /*scatter of mean*/
	   scatterplot x=agegrpn y=mean1/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=trianglefilled color=blue);
	   scatterplot x=agegrpn y=mean2/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=squarefilled color=green);
       scatterplot x=agegrpn y=mean3/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=circlefilled color=grey);

        /*scatter of median*/
	   highlowplot x=agegrpn low=median1 high=median1/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=blue) ;
       highlowplot x=agegrpn low=median2 high=median2/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=green) ;
       highlowplot x=agegrpn low=median3 high=median3/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=grey) ;

        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;trtn&lt;/STRONG&gt;&lt;/FONT&gt;  classdisplay=cluster clusterwidth=0.53 classorder=ascending 
                valueattrs=(weight=bold size=12) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1736125419391.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103486i52120ADFE7B74791/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1736125419391.png" alt="Ksharp_0-1736125419391.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 01:03:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955168#M25218</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-06T01:03:47Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955171#M25219</link>
      <description>Thanks for taking time to make it. I really appreciate it. I tried it unfortunately  the number were adding up from 2009 and 2010. For example first blue group 4 in 2009 and 2010 , so I am expecting to display only 4 count.</description>
      <pubDate>Mon, 06 Jan 2025 01:21:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955171#M25219</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-06T01:21:54Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955173#M25220</link>
      <description>&lt;P&gt;You could set NUM=. when year=2010.&lt;/P&gt;
&lt;P&gt;I think it is easy for you , isn't it ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;

data dummy_data;
length treatment _treatment $ 40;
    set dummy_data;
   _treatment=treatment;
	treatment=cats(_treatment,'2019');
    output; 

    /* Modify for Year 2010 */
    Year = 2010;
    AVAL = AVAL + 1000;
	treatment=cats(_treatment,'2020');
    output; 
run;

proc sort data=dummy_data; 
by treatment agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by treatment agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n mean=mean median=median;
run;
data final;
	merge dummy_data stat(drop=_:);
	by treatment agegrpn; 
	num =1;
if TREATMENT=:'DrugA' then do;mean1=mean;median1=median;end;
if TREATMENT=:'DrugB' then do;mean2=mean;median2=median;end;
if TREATMENT=:'Refer' then do;mean3=mean;median3=median;end;

&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;if year=2010 then call missing(num);&lt;/STRONG&gt;&lt;/FONT&gt;
run;

proc sort data=final;by treatment;run;


proc template;
    define statgraph boxplot;

    begingraph /
datacolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey)
datacontrastcolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey) 
datasymbols=(trianglefilled trianglefilled squarefilled squarefilled circlefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=0.12 offsetmax=0.12 label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        boxplot x=agegrpn y=AVAL / group=treatment groupdisplay=cluster boxwidth=0.56 clusterwidth=0.53  ;

        /*scatter of mean*/
	   scatterplot x=agegrpn y=mean1/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=trianglefilled color=blue);
	   scatterplot x=agegrpn y=mean2/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=squarefilled color=green);
       scatterplot x=agegrpn y=mean3/group=treatment groupdisplay=cluster clusterwidth=0.53  markerattrs=(symbol=circlefilled color=grey);

        /*scatter of median*/
	   highlowplot x=agegrpn low=median1 high=median1/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=blue) ;
       highlowplot x=agegrpn low=median2 high=median2/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=green) ;
       highlowplot x=agegrpn low=median3 high=median3/group=treatment groupdisplay=cluster clusterwidth=0.53 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=grey) ;

        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;trtn&lt;/STRONG&gt;&lt;/FONT&gt;  classdisplay=cluster clusterwidth=0.53 classorder=ascending 
                valueattrs=(weight=bold size=12) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1736126847128.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103487i1BD175A78F49287C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1736126847128.png" alt="Ksharp_0-1736126847128.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 01:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955173#M25220</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-06T01:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955174#M25221</link>
      <description>I should have done that, I tried make it missing instead so I ended up dot symbols in graphs. Your  solution is worked. Thanks again for your help.</description>
      <pubDate>Mon, 06 Jan 2025 01:33:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955174#M25221</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-06T01:33:10Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955187#M25222</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;, How Can I reduce the gap between the two groups? I tried reducing the cluster width, but it did not change anything.&amp;nbsp; Since the bars look too narrow, I wanted to reduce the gap and increase the width.&amp;nbsp; I tried increasing and decreasing the numbers, but it did not work. Is it because of Page width?&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SASuserlot_0-1736142617533.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103492i51D68565A37A550F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SASuserlot_0-1736142617533.png" alt="SASuserlot_0-1736142617533.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 05:55:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955187#M25222</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-06T05:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955190#M25223</link>
      <description>&lt;P&gt;I think you owe me two hundred dollars.&lt;/P&gt;
&lt;P&gt;And you could use options&amp;nbsp; &lt;STRONG&gt;offsetmin= ,offsetmax=, clusterwidht=&lt;/STRONG&gt; to adjust the distance between box.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* Step 1: Create Dummy Dataset */
data dummy_data;
    input Subjid $ Age_Group $ Treatment $ AVAL;
    
    /* Numeric representation for Treatment */
    if Treatment = 'DrugA' then trtn = 1;
    else if Treatment = 'DrugB' then trtn = 2;
    else if Treatment = 'Refer' then trtn = 3;

    /* Numeric representation for Age_Group */
    if Age_Group = '5-13' then agegrpn = 1;
    else if Age_Group = '14-21' then agegrpn = 2;
    else if Age_Group = '22-35' then agegrpn = 3;

    datalines;
S01 5-13 DrugA 6000
S02 5-13 DrugA 7000
S03 5-13 DrugB 8000
S04 5-13 DrugB 9000
S05 5-13 Refer 500
S06 5-13 Refer 12000
S07 5-13 DrugA 10000
S08 5-13 DrugB 11000
S09 5-13 Refer 400
S10 14-21 DrugA 4000
S11 14-21 DrugA 5000
S12 14-21 DrugB 6000
S13 5-13 DrugB 7000
S14 14-21 Refer 1000
S15 14-21 Refer 300
S16 22-35 DrugA 8000
S17 14-21 DrugB 9000
S18 14-21 Refer 100
S19 22-35 DrugA 200
S20 22-35 DrugA 300
S21 22-35 DrugB 400
S22 22-35 DrugB 500
S23 22-35 Refer 50
S24 14-21 Refer 100
S25 22-35 DrugA 600
S26 22-35 DrugB 700
S27 22-35 Refer 150
S28 5-13 DrugA 8000
;
run;

data dummy_data;
length treatment _treatment $ 40;
    set dummy_data;
   _treatment=treatment;
	treatment=cats(_treatment,'2019');
    output; 

    /* Modify for Year 2010 */
    Year = 2010;
    AVAL = AVAL + 1000;
	treatment=cats(_treatment,'2020');
    output; 
run;

proc sort data=dummy_data; 
by treatment agegrpn; 
run;

proc means data=dummy_data nway noprint;
/*	by trtn strat2rn;*/
/*	var pchg;*/
by treatment agegrpn; 
	var aval;
	*output out=statall min= max= median= mean= n= q1 = q3 =/autoname;
	output out=stat n=n mean=mean median=median;
run;
data final;
	merge dummy_data stat(drop=_:);
	by treatment agegrpn; 
	num =1;
if TREATMENT=:'DrugA' then do;mean1=mean;median1=median;end;
if TREATMENT=:'DrugB' then do;mean2=mean;median2=median;end;
if TREATMENT=:'Refer' then do;mean3=mean;median3=median;end;

if year=2010 then call missing(num);
run;

proc sort data=final;by treatment;run;


proc template;
    define statgraph boxplot;

    begingraph /
datacolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey)
datacontrastcolors=(lightblue  lightblue  lightgreen lightgreen   lightgrey  lightgrey) 
datasymbols=(trianglefilled trianglefilled squarefilled squarefilled circlefilled circlefilled);

        /* Define Custom Attributes for Age Groups */
        discreteattrmap name="groupline" / ignorecase=true;
            value 'DrugA' / lineattrs=(color=lightblue pattern=1 thickness=2px)
                markerattrs=(color=lightblue symbol=trianglefilled size=8pt)
                textattrs=(color=lightblue);
            value 'DrugB' / lineattrs=(color=lightgreen pattern=1 thickness=2px)
                markerattrs=(color=green symbol=squarefilled size=8pt)
                textattrs=(color=lightgreen);
            value 'Refer' / lineattrs=(color=grey pattern=1 thickness=2px)
                markerattrs=(color=grey symbol=circlefilled size=8pt)
                textattrs=(color=grey);
        enddiscreteattrmap;

        discreteattrvar attrvar=trtgrp var=trtn attrmap='groupline';

        /* Add Custom Legends */
        legenditem type=markerline name='A' / lineattrs=(color=blue pattern=1 thickness=2px)
            markerattrs=(color=blue size=8pt symbol=trianglefilled)
            label="DrugA" labelattrs=(size=9pt);
        legenditem type=markerline name='B' / lineattrs=(color=green pattern=1 thickness=2px)
            markerattrs=(color=green size=8pt symbol=squarefilled)
            label="DrugB" labelattrs=(size=9pt);
        legenditem type=markerline name='R' / lineattrs=(color=grey pattern=1 thickness=2px)
            markerattrs=(color=grey size=8pt symbol=circlefilled)
            label="Refer" labelattrs=(size=9pt);

        layout overlay / 
            xaxisopts=(offsetmin=&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;0.2&lt;/STRONG&gt;&lt;/FONT&gt; offsetmax=&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;0.2&lt;/STRONG&gt;&lt;/FONT&gt; label="Age Groups" labelattrs=(size=12pt weight=bold) 
                tickvalueattrs=(size=12pt weight=bold))
            yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Results" labelfitpolicy=splitalways labelsplitchar='^' 
                labelattrs=(size=11pt weight=bold) tickvalueattrs=(size=12pt weight=bold) 
                linearopts=(tickvaluesequence=(start=-2000 end=15000 increment=1000) viewmin=-2000 viewmax=15000));

        /* Reference Line */
        referenceline y=0 / lineattrs=(color=grey pattern=3);

        /* Box Plot */
        boxplot x=agegrpn y=AVAL / group=treatment groupdisplay=cluster boxwidth=&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;0.6&lt;/STRONG&gt;&lt;/FONT&gt;  clusterwidth=&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;0.9&lt;/FONT&gt;&lt;/STRONG&gt;  ;

        /*scatter of mean*/
	   scatterplot x=agegrpn y=mean1/group=treatment groupdisplay=cluster clusterwidth=&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;0.9&lt;/FONT&gt; &lt;/STRONG&gt; markerattrs=(symbol=trianglefilled color=blue);
	   scatterplot x=agegrpn y=mean2/group=treatment groupdisplay=cluster clusterwidth=&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;0.9&lt;/FONT&gt;&lt;/STRONG&gt;  markerattrs=(symbol=squarefilled color=green);
       scatterplot x=agegrpn y=mean3/group=treatment groupdisplay=cluster clusterwidth=&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;0.9&lt;/STRONG&gt;&lt;/FONT&gt;  markerattrs=(symbol=circlefilled color=grey);

        /*scatter of median*/
	   highlowplot x=agegrpn low=median1 high=median1/group=treatment groupdisplay=cluster clusterwidth=0.9 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=blue) ;
       highlowplot x=agegrpn low=median2 high=median2/group=treatment groupdisplay=cluster clusterwidth=0.9 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=green) ;
       highlowplot x=agegrpn low=median3 high=median3/group=treatment groupdisplay=cluster clusterwidth=0.9 type=bar barwidth=0.6 outlineattrs=(thickness=2px color=grey) ;

        /* Legend */
        discretelegend 'A' 'B' 'R' / down=1 border=false;

        /* Axis Table */
        innermargin;
            axistable x=agegrpn value=num / class=trtn  classdisplay=cluster clusterwidth=0.9 classorder=ascending 
                valueattrs=(weight=bold size=12) labelattrs=(weight=bold) colorgroup=trtgrp ; 
        endinnermargin;

        endlayout;
    endgraph;
end;
run;
proc format;
   value agegrpn
      1="5-13"
      2="14-21"
      3="22-35"
			;
	value treatment 
		1="DrugA"
		2="DrugB"
		3="Refer"
			;
run;


/* Generate the Graph */
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase  nobyline;

ods escapechar = '^';
ods results on; 
ods listing close; 
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / imagefmt=png attrpriority=none height=4.8 in width=8.5 in border=off;

proc sgrender data=final template=boxplot;
    format trtn treatment. agegrpn agegrpn.;
run;

ods rtf close;
ods listing;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1736145479873.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/103493iB9E046E7BDF015B4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1736145479873.png" alt="Ksharp_0-1736145479873.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Jan 2025 06:39:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955190#M25223</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-01-06T06:39:58Z</dc:date>
    </item>
    <item>
      <title>Re: BOX Plot customization using Proc Template</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955192#M25224</link>
      <description>Thanks. Sorry for bothering. Yes your time definitely worth more than that. Thanks again .</description>
      <pubDate>Mon, 06 Jan 2025 07:21:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/BOX-Plot-customization-using-Proc-Template/m-p/955192#M25224</guid>
      <dc:creator>SASuserlot</dc:creator>
      <dc:date>2025-01-06T07:21:01Z</dc:date>
    </item>
  </channel>
</rss>

