<?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: Discrete legend for proc sgplot heat map in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/573541#M18492</link>
    <description>&lt;P&gt;For future reference, I wrote a blog post that describes how to use PROC SGPLOT to create a discrete heatmap with a discrete legend:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/07/15/create-discrete-heat-map-sgplot.html" target="_self"&gt;Create a discrete heat map with PROC SGPLOT&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 15 Jul 2019 15:21:57 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2019-07-15T15:21:57Z</dc:date>
    <item>
      <title>Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571030#M18406</link>
      <description>&lt;P&gt;Hello all and thank you in advance,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have the below code to produce a heat map. My color response variable is discrete, with values from 1-5. Obviously the "gradlegend" creates the gradient legend, but I don't know what to replace it with to get a discrete legend. As is, the gradient legend both hides my minimum and maximum values for display, and the gradient just doesn't really make sense when the values can only be one of five colors. I tried "discretelegend", which didn't work, and this thread&amp;nbsp;&lt;A href="https://communities.sas.com/t5/Graphics-Programming/Please-explainh-the-illogical-gradlegend-in-following-example/m-p/320170/highlight/true#M11206" target="_blank"&gt;https://communities.sas.com/t5/Graphics-Programming/Please-explainh-the-illogical-gradlegend-in-following-example/m-p/320170/highlight/true#M11206&lt;/A&gt;, which also wasn't the ticket. Does anyone know how to get the legend to display my discrete values? Thank you in advance!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=heatmap;
   heatmap x=relative_wk y=territory / discretex colormodel=(cxFFFF66 cxFFCC00 cxFF9900 cxCC3300 /*cx800000*/ cx910014) colorresponse=Skill_bin 
		   outline;
		 gradlegend  / title="Ensemble Peak Week Forecast Skill";
		 xaxis label="Week Relative to Observed Peak Week";
		 yaxis label="State/Territory"; 
	format Skill_bin b.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SAShelp.png" style="width: 436px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30730iA4571C1F57B00441/image-size/large?v=v2&amp;amp;px=999" role="button" title="SAShelp.png" alt="SAShelp.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV&gt;&lt;DIV class="c"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 03 Jul 2019 17:09:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571030#M18406</guid>
      <dc:creator>chelseaxxlutz</dc:creator>
      <dc:date>2019-07-03T17:09:14Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571234#M18410</link>
      <description>&lt;P&gt;Do you have IML ?&lt;/P&gt;
&lt;P&gt;This example is taken from iml documentation.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc iml;
use Sashelp.Cars;
read all var _NUM_ into Y[c=varNames];
close Sashelp.Cars;
corr = corr(Y);
Bins = {"1: V. Neg", "2: Neg", "3: Neutral", "4: Pos", "5: V. Pos"};
idx = bin(corr, {-1, -0.6, -0.2, 0.2, 0.6, 1});
disCorr = shape(Bins[idx], nrow(corr));


call HeatmapDisc(disCorr) title="Correlations"
xvalues=varNames yvalues=varNames
LegendTitle="Magnitude";
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jul 2019 12:24:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571234#M18410</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-04T12:24:59Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571358#M18415</link>
      <description>&lt;P&gt;If you've got a fairly recent version of SAS, one way to do it would be to use the new 'legenditem' statement to custom-create each item you want in the legend ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data heatmap; set sashelp.us_data (where=(statecode not in ('DC' 'PR')));&lt;BR /&gt;territory=statename;&lt;BR /&gt;do relative_wk = -6 to 6 by 1;&lt;BR /&gt;Skill_bin = rand("Integer", 1, 10);&lt;BR /&gt;output;&lt;BR /&gt;end;&lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;ods graphics / width=600px height=900px;&lt;BR /&gt;proc sgplot data=heatmap;&lt;BR /&gt;heatmap x=relative_wk y=territory / discretex &lt;BR /&gt;&amp;nbsp; &amp;nbsp;colormodel=(cxFFFF66 cxFFCC00 cxFF9900 cxCC3300 cx910014) &lt;BR /&gt;&amp;nbsp; &amp;nbsp;colorresponse=Skill_bin outline name='heat';&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;legenditem type=marker name='one' / label='1' markerattrs=(symbol=squarefilled size=9pt color=cxFFFF66);&lt;BR /&gt;legenditem type=marker name='two' / label='2' markerattrs=(symbol=squarefilled size=9pt color=cxFFCC00);&lt;BR /&gt;legenditem type=marker name='three' / label='3' markerattrs=(symbol=squarefilled size=9pt color=cxFF9900);&lt;BR /&gt;legenditem type=marker name='four' / label='4' markerattrs=(symbol=squarefilled size=9pt color=cxCC3300);&lt;BR /&gt;legenditem type=marker name='five' / label='5' markerattrs=(symbol=squarefilled size=9pt color=cx910014);&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;keylegend 'one' 'two' 'three' 'four' 'five' / title="Ensemble Peak Week Forecast Skill";&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;xaxis label="Week Relative to Observed Peak Week";&lt;BR /&gt;yaxis label="State/Territory" valueattrs=(size=8pt); &lt;BR /&gt;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="heatmap.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30767i51A0330B007423BC/image-size/large?v=v2&amp;amp;px=999" role="button" title="heatmap.png" alt="heatmap.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 05 Jul 2019 11:42:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571358#M18415</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2019-07-05T11:42:52Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571667#M18419</link>
      <description>&lt;P&gt;I would switch to the HEATMAPPARM statement with the COLORGROUP= option. You can then use the DISCRETELEGEND statement to get the legend. For an example of syntax, see the last code segment at&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2017/04/26/visualize-design-matrix.html" target="_blank"&gt;https://blogs.sas.com/content/iml/2017/04/26/visualize-design-matrix.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;(and add a DISCRETELEGEND statement).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assumes that you have one observation per cell. That is, the data are pre-summarized into bins.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 07 Jul 2019 19:44:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571667#M18419</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-07-07T19:44:10Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571758#M18421</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you. The HEATMAPPARM statement worked halfway. Using the below code, I now get my discrete legend (yay!). However, my XAXIS is no longer discrete (i.e., instead of -6 to 6 by 1, I get -5 to 5 by 2.5), and any statement I add to fix that doesn't work...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=heatmap;
   heatmapparm x=relative_wk y=territory colorgroup=Skill_bin / 
			   colormodel=(cxFFFF66 cxFFCC00 cxFF9900 cxCC3300 cx910014)  
		   	   outline;
		 discretelegend  / title="Ensemble Peak Week Forecast Skill";
		 xaxis label="Week Relative to Observed Peak Week";
		 yaxis label="State/Territory"; 
	format Skill_bin b.;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I had "discretex" in the layout statement after the slash and before the outline argument. I received this error&lt;/P&gt;&lt;PRE&gt;WARNING: HEATMAPPARM statement has a conflict with the axis type. The plot will not be drawn.&amp;nbsp;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, as per SAS support (&lt;A href="http://support.sas.com/kb/55/717.html" target="_blank" rel="noopener"&gt;http://support.sas.com/kb/55/717.html&lt;/A&gt;), I changed it to "Discretex=true" and just got a syntax error/nothing ran.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class="branch"&gt;&lt;DIV class="c"&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Incorrectheatmap.png" style="width: 436px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/30822i2EDF731C06D69BD4/image-size/large?v=v2&amp;amp;px=999" role="button" title="Incorrectheatmap.png" alt="Incorrectheatmap.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV class="c"&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class="c"&gt;So, in summary, the above legend is what I want, but the x axis isn't right anymore.&amp;nbsp;Any idea how I can get my original x axis back? Thank you!!&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571758#M18421</guid>
      <dc:creator>chelseaxxlutz</dc:creator>
      <dc:date>2019-07-08T13:05:09Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571759#M18422</link>
      <description>Rick is right. Check &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2016/05/20/ctspedia-graphs-heatmap-of-benefit-and-risk/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2016/05/20/ctspedia-graphs-heatmap-of-benefit-and-risk/&lt;/A&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:14:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571759#M18422</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-08T13:14:25Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571760#M18423</link>
      <description>Rick is right. Check &lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2016/05/20/ctspedia-graphs-heatmap-of-benefit-and-risk/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2016/05/20/ctspedia-graphs-heatmap-of-benefit-and-risk/&lt;/A&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:14:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571760#M18423</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2019-07-08T13:14:36Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571762#M18424</link>
      <description>&lt;P&gt;1. Delete your COLORMODEL= option. That only applies to a continuous color response variable.&lt;/P&gt;
&lt;P&gt;2. Add DISCRETEX option to the HEATMAPPARM statement.&lt;/P&gt;
&lt;P&gt;3. If you use the XAXIS statement, you also need to add TYPE=DISCRETE to that statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data heatmap; 
set sashelp.us_data (where=(statecode not in ('DC' 'PR')));
territory=statename;
do relative_wk = -6 to 6 by 1;
   Skill_bin = rand("Integer", 1, 5);
   output;
end;
run;

title;
ods graphics / height=800px width=480px;
proc sgplot data=heatmap;
   heatmapparm x=relative_wk y=territory colorgroup=Skill_bin / 
      	   outline discretex;
   keylegend  / title="Ensemble Peak Week Forecast Skill";
   xaxis type=discrete label="Week Relative to Observed Peak Week";
   yaxis reverse label="State/Territory"; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jul 2019 13:31:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571762#M18424</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-07-08T13:31:46Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571806#M18428</link>
      <description>Thank you very much!</description>
      <pubDate>Mon, 08 Jul 2019 15:03:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/571806#M18428</guid>
      <dc:creator>chelseaxxlutz</dc:creator>
      <dc:date>2019-07-08T15:03:36Z</dc:date>
    </item>
    <item>
      <title>Re: Discrete legend for proc sgplot heat map</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/573541#M18492</link>
      <description>&lt;P&gt;For future reference, I wrote a blog post that describes how to use PROC SGPLOT to create a discrete heatmap with a discrete legend:&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/iml/2019/07/15/create-discrete-heat-map-sgplot.html" target="_self"&gt;Create a discrete heat map with PROC SGPLOT&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2019 15:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Discrete-legend-for-proc-sgplot-heat-map/m-p/573541#M18492</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2019-07-15T15:21:57Z</dc:date>
    </item>
  </channel>
</rss>

