<?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: Format messes up colors in HEATMAPPARM in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/573120#M161759</link>
    <description>&lt;P&gt;And &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;you save the day again! Thank you very much!&lt;/P&gt;</description>
    <pubDate>Fri, 12 Jul 2019 14:51:12 GMT</pubDate>
    <dc:creator>chelseaxxlutz</dc:creator>
    <dc:date>2019-07-12T14:51:12Z</dc:date>
    <item>
      <title>Format messes up colors in HEATMAPPARM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/572885#M161688</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is a follow up to my post about a week ago creating a heat map using HEATMAPPARM to generate a discrete legend. Using the below code, I finally have the exact graph I want.... almost. It appears that by using an attribute map, I am no longer able to apply my formats? Below are my images and code.&amp;nbsp;The teal-brown-purple graph has the correct formats applied, but the colors don't work. The yellow-orange-red one is the color I want, but my legend does not have the format. Would anyone know why these two pieces of code don't want to work together? I am using SAS 9.4 Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code WITH format that produces wrong colors:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*formats for skill bin labels*/
proc format;
value sb
	   1="0.01-0.05"
	   2="0.05-0.20"
	   3="0.20-0.35"
	   4="0.35-0.50"
	   5="0.50-1.00";
run;


/*create attribute map for cell colors*/
data Attrs;
length Value 8. FillColor $20;
ID = "skill_bin";
Value = 1; FillColor="cxFFFF66"; output;
Value = 2; FillColor="cxFFCC00"; output;
Value = 3; FillColor="cxFF9900"; output;
Value = 4; FillColor="cxCC3300"; output;
Value = 5; FillColor="cx910014"; output;
run;


/*create heat map for each state/territory of ensemble peak week skill and number of weeks pre/post peak week*/
title "State-specific ensemble model skill for peak week, relative to observed peak week, per state/territory";
ods graphics / height=1100px width=900px;
proc sgplot data=heatmap dattrmap=Attrs;
   heatmapparm x=relative_wk y=territory colorgroup=skill_bin / attrid=skill_bin outline discretex discretey;
   keylegend  / title="Ensemble Peak Week Forecast Skill" across=5 sortorder=ascending titleattrs=(size=8) valueattrs=(size=8);
   xaxis type=discrete label="Week Relative to Observed Peak Week" labelattrs=(size=8 weight=bold) valueattrs=(size=8);
   yaxis type=discrete label="State/Territory" labelattrs=(size=8 weight=bold) valueattrs=(size=8);
   format Skill_bin sb. location loc.; 
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wrong1.png" style="width: 491px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30990i49780FB545076356/image-size/large?v=v2&amp;amp;px=999" role="button" title="wrong1.png" alt="wrong1.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;Code WITHOUT format that produces correct colors, but I lose my legend labels:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*formats for skill bin labels and state/territory names*/
proc format;
value sb
	   1="0.01-0.05"
	   2="0.05-0.20"
	   3="0.20-0.35"
	   4="0.35-0.50"
	   5="0.50-1.00";
run;


/*create attribute map for cell colors*/
data Attrs;
length Value 8. FillColor $20;
ID = "skill_bin";
Value = 1; FillColor="cxFFFF66"; output;
Value = 2; FillColor="cxFFCC00"; output;
Value = 3; FillColor="cxFF9900"; output;
Value = 4; FillColor="cxCC3300"; output;
Value = 5; FillColor="cx910014"; output;
run;


/*create heat map for each state/territory of ensemble peak week skill and number of weeks pre/post peak week*/
title "State-specific ensemble model skill for peak week, relative to observed peak week, per state/territory";
ods graphics / height=1100px width=900px;
proc sgplot data=heatmap dattrmap=Attrs;
   heatmapparm x=relative_wk y=territory colorgroup=skill_bin / attrid=skill_bin outline discretex discretey;
   keylegend  / title="Ensemble Peak Week Forecast Skill" across=5 sortorder=ascending titleattrs=(size=8) valueattrs=(size=8);
   xaxis type=discrete label="Week Relative to Observed Peak Week" labelattrs=(size=8 weight=bold) valueattrs=(size=8);
   yaxis type=discrete label="State/Territory" labelattrs=(size=8 weight=bold) valueattrs=(size=8);
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="wrong2.png" style="width: 491px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30989iE2F7D602AED1DB12/image-size/large?v=v2&amp;amp;px=999" role="button" title="wrong2.png" alt="wrong2.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This one really has me stuck. Is it something as simple as the format needs to go in the attribute map? I admit I'm not very familiar with making one. Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 18:29:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/572885#M161688</guid>
      <dc:creator>chelseaxxlutz</dc:creator>
      <dc:date>2019-07-11T18:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Format messes up colors in HEATMAPPARM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/572923#M161702</link>
      <description>&lt;P&gt;The attribute maps should refer to the FORMATTED values. Those are the values that determine the groups:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/*create attribute map for cell colors*/
data Attrs;
length Value $10 FillColor $15;
input raw FillColor;
Value = put(raw, SB.);            /* use format to assign values */
retain ID "skill_bin";
datalines;
1 cxFFFF66
2 cxFFCC00
3 cxFF9900
4 cxCC3300
5 cx910014
;

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;When you use a discrete attribute map, you shouldn't need the SORTORDER= option on the KEYLEGEND statement.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2019 19:57:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/572923#M161702</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-07-11T19:57:51Z</dc:date>
    </item>
    <item>
      <title>Re: Format messes up colors in HEATMAPPARM</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/573120#M161759</link>
      <description>&lt;P&gt;And &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;you save the day again! Thank you very much!&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2019 14:51:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Format-messes-up-colors-in-HEATMAPPARM/m-p/573120#M161759</guid>
      <dc:creator>chelseaxxlutz</dc:creator>
      <dc:date>2019-07-12T14:51:12Z</dc:date>
    </item>
  </channel>
</rss>

