<?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: proc sgplot. no color in legend to match bar graph in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-no-color-in-legend-to-match-bar-graph/m-p/895835#M353939</link>
    <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" target="_self"&gt;#Maxim1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_043/grstatproc/p0hc32jtfqoy1fn1h5i38q8v9py2.htm#n00jwj7lumri74n15g2aezqm8f3h" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/v_043/grstatproc/p0hc32jtfqoy1fn1h5i38q8v9py2.htm#n00jwj7lumri74n15g2aezqm8f3h&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also use attrmap top be sure that colors "match":&amp;nbsp;&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data attrmapfruit;
retain linecolor "black";
input id $ value $ fillcolor $;
datalines;
sex F red
sex M blue
;
run;



proc sgplot data=sashelp.class dattrmap=attrmapfruit;

	vbar age/response=height group=sex groupdisplay=cluster attrid=sex;

  label height='height label'
		  sex='sex label'
		  age='age label';  

	 legenditem type=FILL name='F' / FILLATTRS=(color=red) label='F label';
	 legenditem type=FILL name='M' / FILLATTRS=(color=blue) label='M label' ;
	keylegend  "F" "M";
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1695709835302.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88332i8DDF3B49EADDBD0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1695709835302.png" alt="yabwon_0-1695709835302.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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
    <pubDate>Tue, 26 Sep 2023 06:32:17 GMT</pubDate>
    <dc:creator>yabwon</dc:creator>
    <dc:date>2023-09-26T06:32:17Z</dc:date>
    <item>
      <title>proc sgplot. no color in legend to match bar graph</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-no-color-in-legend-to-match-bar-graph/m-p/895830#M353936</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;my legend does not have any colors to match with the bargraph. not sure how to fix it&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HitmonTran_1-1695704904509.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88330iB571DAFA5246FAB6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HitmonTran_1-1695704904509.png" alt="HitmonTran_1-1695704904509.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;code:&lt;/STRONG&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc sgplot data=graph;&lt;BR /&gt;
	vbar var/response=varn    group=txt groupdisplay=cluster;
	 label varn='% of Patients'
		  var=''
		  txt='Visit Time';  &lt;BR /&gt;
	 legenditem type=FILL name='Baseline' /label='Baseline (N=&amp;amp;two1n)'  ;
	 legenditem type=FILL name='Usage' /label='60-Month followup (N=&amp;amp;two2n)';
	keylegend  "Baseline" "Usage";
run; &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 05:08:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-no-color-in-legend-to-match-bar-graph/m-p/895830#M353936</guid>
      <dc:creator>HitmonTran</dc:creator>
      <dc:date>2023-09-26T05:08:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot. no color in legend to match bar graph</title>
      <link>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-no-color-in-legend-to-match-bar-graph/m-p/895835#M353939</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/Maxims-of-Maximally-Efficient-SAS-Programmers/ta-p/352068/show-comments/false" target="_self"&gt;#Maxim1&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/v_043/grstatproc/p0hc32jtfqoy1fn1h5i38q8v9py2.htm#n00jwj7lumri74n15g2aezqm8f3h" target="_blank" rel="noopener"&gt;https://documentation.sas.com/doc/en/pgmsascdc/v_043/grstatproc/p0hc32jtfqoy1fn1h5i38q8v9py2.htm#n00jwj7lumri74n15g2aezqm8f3h&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also use attrmap top be sure that colors "match":&amp;nbsp;&amp;nbsp;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/p18q268a3zxcl3n11lnnnq4cme8r.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data attrmapfruit;
retain linecolor "black";
input id $ value $ fillcolor $;
datalines;
sex F red
sex M blue
;
run;



proc sgplot data=sashelp.class dattrmap=attrmapfruit;

	vbar age/response=height group=sex groupdisplay=cluster attrid=sex;

  label height='height label'
		  sex='sex label'
		  age='age label';  

	 legenditem type=FILL name='F' / FILLATTRS=(color=red) label='F label';
	 legenditem type=FILL name='M' / FILLATTRS=(color=blue) label='M label' ;
	keylegend  "F" "M";
run; &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="yabwon_0-1695709835302.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/88332i8DDF3B49EADDBD0B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="yabwon_0-1695709835302.png" alt="yabwon_0-1695709835302.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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bart&lt;/P&gt;</description>
      <pubDate>Tue, 26 Sep 2023 06:32:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/proc-sgplot-no-color-in-legend-to-match-bar-graph/m-p/895835#M353939</guid>
      <dc:creator>yabwon</dc:creator>
      <dc:date>2023-09-26T06:32:17Z</dc:date>
    </item>
  </channel>
</rss>

