<?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: Flipped colors in SGPANEL in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767178#M21952</link>
    <description>&lt;P&gt;Thanks for the explanation and example,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10604"&gt;@djrisks&lt;/a&gt;&amp;nbsp;. But I'm still getting the same result even though I copied your code (I mean I didn't miss anything from your code for sure)&lt;/P&gt;</description>
    <pubDate>Sat, 11 Sep 2021 03:35:39 GMT</pubDate>
    <dc:creator>Jack_Loktiev</dc:creator>
    <dc:date>2021-09-11T03:35:39Z</dc:date>
    <item>
      <title>Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767119#M21949</link>
      <description>&lt;P&gt;Hi everyone.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I noticed that when I do several SGPANELS with&amp;nbsp;styleattrs datacolors specified and GROUP option the color of the groups gets flipped from one SGPANEL to another. Here is my code:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test1;
input channel $ product $ available $ month count;
cards;
CH1 PROD1 YES 1 1
CH1 PROD1 NO 2 1
CH2 PROD2 NO 1 2
CH2 PROD1 NO 3 5
CH2 PROD3 YES 1 2
CH3 PROD1 YES 1 5
CH3 PROD2 NO 2 2
CH3 PROD3 YES 4 1
;
run;

ODS HTML;
proc sgpanel data= test1;
where channel = 'CH1';
styleattrs datacolors=(cx5e2750 cx5bbbb7);
panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
vbar MONTH / response=count DATALABEL=count group=available GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;

proc sgpanel data= test1;
where channel = 'CH2';
styleattrs datacolors=(cx5e2750 cx5bbbb7);
panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
vbar MONTH / response=count DATALABEL=count group=available GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;

proc sgpanel data= test1;
where channel = 'CH3';
styleattrs datacolors=(cx5e2750 cx5bbbb7);
panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
vbar MONTH / response=count DATALABEL=count group=available GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And here is what I'm getting:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAS question.PNG" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63502i945CBEF0EA12EB4D/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAS question.PNG" alt="SAS question.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;On the first panel, NO is purple and YES is olive. On the second one, it is the other way around.&lt;/P&gt;&lt;P&gt;Why is that and how to keep colors consistent?&lt;/P&gt;</description>
      <pubDate>Fri, 10 Sep 2021 20:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767119#M21949</guid>
      <dc:creator>Jack_Loktiev</dc:creator>
      <dc:date>2021-09-10T20:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767121#M21950</link>
      <description>When procs use STYLEATTRS they just cycle through the list, if a column is missing it throws everything off or if the order changes. &lt;BR /&gt;&lt;BR /&gt;Discrete Data Attribute maps solve this issue. &lt;BR /&gt;&lt;A href="https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm#:~:text=Discrete%20Attribute%20Maps-,A%20discrete%20attribute%20map%20data%20set%20can%20contain%20more%20than,has%20more%20than%20one%20value" target="_blank"&gt;https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n18szqcwir8q2nn10od9hhdh2ksj.htm#:~:text=Discrete%20Attribute%20Maps-,A%20discrete%20attribute%20map%20data%20set%20can%20contain%20more%20than,has%20more%20than%20one%20value&lt;/A&gt;.</description>
      <pubDate>Fri, 10 Sep 2021 20:27:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767121#M21950</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-09-10T20:27:51Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767144#M21951</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/377388"&gt;@Jack_Loktiev&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt;&amp;nbsp;mentioned, you should use attribute maps to get consistent colours. The reason why it is switching is because for some channels and products the value of "NO" is first and for other channels and products the value of "YES" is first. Below shows an example (with help from the SAS help guide) of how you can incorporate attribute maps by using the discrete attribute map dataset along with the&amp;nbsp;&lt;STRONG&gt;dattrmap=myattrmap&lt;/STRONG&gt; and &lt;STRONG&gt;attrid=myid&lt;/STRONG&gt; options. As you can see you do not need to use the &lt;STRONG&gt;styleattrs&lt;/STRONG&gt; option now.&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;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test1;
input channel $ product $ available $ month count;
cards;
CH1 PROD1 YES 1 1
CH1 PROD1 NO 2 1
CH2 PROD2 NO 1 2
CH2 PROD1 NO 3 5
CH2 PROD3 YES 1 2
CH3 PROD1 YES 1 5
CH3 PROD2 NO 2 2
CH3 PROD3 YES 4 1
;
run;

data myattrmap;
  length fillcolor $ 9;
  input ID $ value $ fillcolor $;
  datalines;
myid  YES cx5bbbb7
myid  NO  cx5e2750
;
run;

ODS HTML;
proc sgpanel data= test1 dattrmap=myattrmap;
  where channel = 'CH1';
  panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
  vbar MONTH / response=count DATALABEL=count group=available attrid=myid GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
  rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;

proc sgpanel data= test1 dattrmap=myattrmap;
  where channel = 'CH2';
  panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
  vbar MONTH / response=count DATALABEL=count group=available attrid=myid GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
  rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;

proc sgpanel data= test1 dattrmap=myattrmap;
  where channel = 'CH3';
  panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
  vbar MONTH / response=count DATALABEL=count group=available attrid=myid GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
  rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
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>Fri, 10 Sep 2021 21:44:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767144#M21951</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2021-09-10T21:44:22Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767178#M21952</link>
      <description>&lt;P&gt;Thanks for the explanation and example,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10604"&gt;@djrisks&lt;/a&gt;&amp;nbsp;. But I'm still getting the same result even though I copied your code (I mean I didn't miss anything from your code for sure)&lt;/P&gt;</description>
      <pubDate>Sat, 11 Sep 2021 03:35:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767178#M21952</guid>
      <dc:creator>Jack_Loktiev</dc:creator>
      <dc:date>2021-09-11T03:35:39Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767184#M21953</link>
      <description>&lt;P&gt;You're welcome &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/377388"&gt;@Jack_Loktiev&lt;/a&gt;. When I run the code, I get the greenish colour for YES and the reddish colour for NO. Do you see any warnings in the log when you run the code? Perhaps it could be your SAS version. Are you definitely looking at the latest 3 plots?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I noticed in the legend in the second plot, the NO value is before the YES value. But, the colours are still consistent.&lt;/P&gt;</description>
      <pubDate>Sat, 11 Sep 2021 07:06:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767184#M21953</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2021-09-11T07:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767201#M21954</link>
      <description>&lt;P&gt;I think you already get the solution by Reeza an djrisks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or padding these missing month and yes_no.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;Data test1;
input channel $ product $ available $ month count;
cards;
CH1 PROD1 YES 1 1
CH1 PROD1 NO 2 1
CH2 PROD2 NO 1 2
CH2 PROD1 NO 3 5
CH2 PROD3 YES 1 2
CH3 PROD1 YES 1 5
CH3 PROD2 NO 2 2
CH3 PROD3 YES 4 1
;
run;

proc sql;
create table test2 as
select *
 from (select * from 
(select distinct channel from test1),
(select distinct product from test1),
(select distinct available from test1),
(select distinct month from test1)) as a
natural left join test1 as b;
quit;

proc sgpanel data= test2;
where channel = 'CH1';
styleattrs datacolors=(cx5e2750 cx5bbbb7);
panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
vbar MONTH / 
response=count DATALABEL=count group=available GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;
proc sgpanel data= test2;
where channel = 'CH2';
styleattrs datacolors=(cx5e2750 cx5bbbb7);
panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
vbar MONTH / 
 response=count DATALABEL=count group=available GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33) ;
run;
proc sgpanel data= test2;
where channel = 'CH3';
styleattrs datacolors=(cx5e2750 cx5bbbb7);
panelby PRODUCT/ novarname columns=3 rows = 1 spacing=10 border uniscale=all;
vbar MONTH / 
response=count DATALABEL=count group=available GROUPDISPLAY=CLUSTER DATALABELFITPOLICY=NONE DATASKIN = GLOSS   DATALABELattrs = (COLOR = CX4D4D4D) NOOUTLINE fillattrs= (TRANSPARENCY= .6);
rowaxis display=(nolabel noline noticks) grid offsetmin=0 offsetmax=0  valueattrs=(color=gray33);
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 11 Sep 2021 12:05:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767201#M21954</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-11T12:05:43Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767403#M21957</link>
      <description>I restarted SAS session and it works now. Thank you very much, &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/10604"&gt;@djrisks&lt;/a&gt;.</description>
      <pubDate>Mon, 13 Sep 2021 13:11:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767403#M21957</guid>
      <dc:creator>Jack_Loktiev</dc:creator>
      <dc:date>2021-09-13T13:11:07Z</dc:date>
    </item>
    <item>
      <title>Re: Flipped colors in SGPANEL</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767404#M21958</link>
      <description>That's great, and you're welcome!</description>
      <pubDate>Mon, 13 Sep 2021 13:22:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Flipped-colors-in-SGPANEL/m-p/767404#M21958</guid>
      <dc:creator>djrisks</dc:creator>
      <dc:date>2021-09-13T13:22:25Z</dc:date>
    </item>
  </channel>
</rss>

