<?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: How to Customize the Key legend  PROC SGPLOT in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969603#M25588</link>
    <description>&lt;P&gt;It worked, thank you.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jun 2025 14:22:57 GMT</pubDate>
    <dc:creator>xiong</dc:creator>
    <dc:date>2025-06-24T14:22:57Z</dc:date>
    <item>
      <title>How to Customize the Key legend  PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969522#M25586</link>
      <description>&lt;P&gt;I am trying to create the box plot. I want to customize the x axis label and the Key legend Text. How can I&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;ODS ESCAPECHAR = '^';
ods rtf file = "C:\temp\test.rtf" ; 
ods graphics on / attrpriority=none reset=all width=8.0in height=4.5in border=off;


proc sgplot data=sashelp.class noautolegend;
    styleattrs datacolors=(lightgreen lightblue)
               datacontrastcolors=(blue green)
               datasymbols=(Trianglefilled squarefilled );

    vbox height / category=sex 
                 groupdisplay=cluster 
                 name='vbox'
                 boxwidth=0.2;


    xaxis label="sex"
          offsetmax=0.12 
          labelattrs=(size=9pt weight=bold family='Arial') 
          valueattrs=(weight=bold size=9pt family='Arial');

    yaxis label="height"
          min=-10 max=100 
          values=(-10 to 100 by 10)
          labelattrs=(size=10pt weight=bold)
          valueattrs=(weight=bold size=9pt family='Arial') 
          fitpolicy=none;

    refline 0 / axis=y lineattrs=(color=grey pattern=3);

    keylegend 'vbox' / title="sex"
                     location=outside 
                     position=bottom 
                     valueattrs=(family='Arial' size=10pt)
                     titleattrs=(weight=bold family='Arial' size=10pt) 
                     noborder;
run;
ods rtf close;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;achieve this?&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="xiong_0-1750650567399.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/107954i3B57B55E43DCC819/image-size/medium?v=v2&amp;amp;px=400" role="button" title="xiong_0-1750650567399.png" alt="xiong_0-1750650567399.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 23 Jun 2025 03:50:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969522#M25586</guid>
      <dc:creator>xiong</dc:creator>
      <dc:date>2025-06-23T03:50:01Z</dc:date>
    </item>
    <item>
      <title>Re: How to Customize the Key legend  PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969546#M25587</link>
      <description>&lt;P&gt;Give this code a try, you might need to adapt it to your needs. It uses a format to display F as Female and M as Male. It makes use of Proc SQL to count the number F and M and write tem into a macro variable. These macro variables are then used for the legenditems.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
value $gender
 "F" = "Female"
 "M" = "Male"
 ;
run;

proc sql ;
  select
    sum(sex="F") as fCount
    , sum(sex = "M") as mCount
  into
    :fCount
    , :mCount
  from
    sashelp.class
  ;
quit;
proc sgplot data=sashelp.class noautolegend;
  format sex $gender.;
    styleattrs datacolors=(lightgreen lightblue)
               datacontrastcolors=(blue green)
               datasymbols=(Trianglefilled squarefilled );

    vbox height / category=sex 
                 groupdisplay=cluster 
                 name='vbox'
                 boxwidth=0.2;


    xaxis label="sex"
          offsetmax=0.12 
          labelattrs=(size=9pt weight=bold family='Arial') 
          valueattrs=(weight=bold size=9pt family='Arial');

    yaxis label="height"
          min=-10 max=100 
          values=(-10 to 100 by 10)
          labelattrs=(size=10pt weight=bold)
          valueattrs=(weight=bold size=9pt family='Arial') 
          fitpolicy=none;

    refline 0 / axis=y lineattrs=(color=grey pattern=3);

    legenditem TYPE=text name="fCount" / text="&amp;amp;fCount Females" ;
    
    legenditem TYPE=text name="mCount" / text="&amp;amp;mCount Males" ;
 
    keylegend "fCount"  / 
                     location=outside 
                     position=bottom 
                     noborder
;
    keylegend "mCount"  / 
                     location=outside 
                     position=bottom 
                     noborder
                     ;
     
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 23 Jun 2025 15:42:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969546#M25587</guid>
      <dc:creator>BrunoMueller</dc:creator>
      <dc:date>2025-06-23T15:42:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to Customize the Key legend  PROC SGPLOT</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969603#M25588</link>
      <description>&lt;P&gt;It worked, thank you.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jun 2025 14:22:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-Customize-the-Key-legend-PROC-SGPLOT/m-p/969603#M25588</guid>
      <dc:creator>xiong</dc:creator>
      <dc:date>2025-06-24T14:22:57Z</dc:date>
    </item>
  </channel>
</rss>

