<?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 PROC SGPLOT: How to get consistent colors across BY groups? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668774#M20194</link>
    <description>&lt;P&gt;When I run this code, for the first BY group (Origin=Asia), the legend shows that SUV is represented by the red circle. In the second BY group (Origin=Europe), SUV is represented by the cyan color circle. How can I get consistent colors across BY groups, so that each group has the same color in each plot?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
	by origin;
run;
proc sgplot data=cars;
	styleattrs datacontrastcolors=(red green blue cyan magenta orange black);
	by origin;
	scatter x=msrp y=mpg_city/group=type;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 629px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47083iCA28B8B468269DE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 628px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47084i53A6F5E9B3DADE7E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jul 2020 11:06:41 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2020-07-13T11:06:41Z</dc:date>
    <item>
      <title>PROC SGPLOT: How to get consistent colors across BY groups?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668774#M20194</link>
      <description>&lt;P&gt;When I run this code, for the first BY group (Origin=Asia), the legend shows that SUV is represented by the red circle. In the second BY group (Origin=Europe), SUV is represented by the cyan color circle. How can I get consistent colors across BY groups, so that each group has the same color in each plot?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
	by origin;
run;
proc sgplot data=cars;
	styleattrs datacontrastcolors=(red green blue cyan magenta orange black);
	by origin;
	scatter x=msrp y=mpg_city/group=type;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 629px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47083iCA28B8B468269DE2/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture2.PNG" style="width: 628px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/47084i53A6F5E9B3DADE7E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture2.PNG" alt="Capture2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 11:06:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668774#M20194</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-13T11:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: How to get consistent colors across BY groups?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668780#M20195</link>
      <description>&lt;P&gt;Hello, you can use Discrete Attribute Maps to achieve the consistency between groups. This is because generally, the attributes for the group are determined by the order that the value is within the data. Using discrete attribute maps can make you indicate the colors that you want to assign to each group value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;There are more details here:&amp;nbsp;&lt;A href="https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=n18szqcwir8q2nn10od9hhdh2ksj.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en"&gt;https://documentation.sas.com/?docsetId=grstatproc&amp;amp;docsetTarget=n18szqcwir8q2nn10od9hhdh2ksj.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is an example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sort data=sashelp.cars out=cars;
  by origin;
run;

data myattrmap;
  length markercolor $ 7 markersymbol $ 6;
  input id $ value $ markercolor $ markersymbol $;
datalines;
myid Hybrid red circle
myid SUV green circle
myid Sedan blue circle
myid Sports cyan circle
myid Truck magenta circle
myid Wagon orange circle 
;
run;

proc sgplot data=cars dattrmap=myattrmap;
  by origin;
  scatter x=msrp y=mpg_city/group=type attrid=myid;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Jul 2020 11:27:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668780#M20195</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2020-07-13T11:27:34Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: How to get consistent colors across BY groups?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668788#M20196</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10604"&gt;@djrisks&lt;/a&gt;. I think I should have thought of that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyway, I discovered that when you do this on my&amp;nbsp;&lt;EM&gt;real&lt;/EM&gt; data, which uses custom formats, the value in the MYATTRMAP must be the formatted value, not the unformatted value.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 11:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668788#M20196</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2020-07-13T11:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: How to get consistent colors across BY groups?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668806#M20197</link>
      <description>&lt;P&gt;You're welcome&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10892"&gt;@PaigeMiller&lt;/a&gt;&amp;nbsp;. Yes, that's true about the formatted values.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 13:10:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668806#M20197</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2020-07-13T13:10:58Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: How to get consistent colors across BY groups?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668885#M20199</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;For an introduction to discrete attribute maps, see the articles&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2012/02/27/roses-are-red-violets-are-blue/" target="_self"&gt;"Roses are red, violets are blue"&lt;/A&gt; by Dan Heath&lt;/P&gt;
&lt;P&gt;or&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2014/10/19/consistent-group-colors-by-value/" target="_self"&gt;"Consistent groups colors by value"&lt;/A&gt; by Sanjay Matange&lt;/P&gt;
&lt;P&gt;For advanced users, see &lt;A href="https://blogs.sas.com/content/iml/2017/01/30/auto-discrete-attr-map.html" target="_self"&gt;"Automate the creation of a discrete attribute map"&lt;/A&gt;&amp;nbsp;by Rick Wicklin&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jul 2020 16:57:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-How-to-get-consistent-colors-across-BY-groups/m-p/668885#M20199</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-07-13T16:57:54Z</dc:date>
    </item>
  </channel>
</rss>

