<?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: Sandarizing colour scale in heatmap in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771101#M244646</link>
    <description>&lt;P&gt;Have you tried using the COLORGROUP variable?&lt;/P&gt;
&lt;P&gt;See &lt;A href="https://www.lexjansen.com/sesug/2017/RIV-138.pdf" target="_self"&gt;this&lt;/A&gt;&amp;nbsp;and &lt;A href="https://www.pharmasug.org/proceedings/2021/DV/PharmaSUG-2021-DV-078.pdf" target="_self"&gt;this&lt;/A&gt; examples.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Sep 2021 10:23:12 GMT</pubDate>
    <dc:creator>ChrisNZ</dc:creator>
    <dc:date>2021-09-29T10:23:12Z</dc:date>
    <item>
      <title>Sandarizing colour scale in heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771099#M244644</link>
      <description>&lt;P&gt;Hi everyone,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using sgplot to create heat-maps to present data form a table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;It is a great functionally, but I am struggling with the colour scale for the heat map.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Basically, i am generating several heat maps, based on data from a table, the min and max for the data in each heat map are slightly different, resulting in the colour scale (autogenerated by SGPLIT) being different between the different heat maps, and hence the user cannot appreciate the difference easily.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TO illustrate this, see the following code:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Generate a table with random numbers;

Data have;
	do a= 1 to 3;
		do i=1 to 5;
			L=1;
			o=floor(rand('Uniform')*10);
			output;
		end;
	output;
	end;


	do a= 1 to 3;
		do i=1 to 5;
			L=2;
			o=floor(rand('Uniform')*5)+2; 
			output;
		end;
	output;
	end;

run;


*Generate heat-maps;

proc sgplot data=have;
   heatmapparm x=a y=i colorresponse=o / outline discretex colormodel=ThreeColorRamp;
   text x=a y=i text=o / textattrs=(size=10pt) strip;
   by L ;
   gradlegend;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you will notice that the code above generates two heat maps but that cells containing the same number (say 6) in the two heat maps have different colour shades.&lt;/P&gt;
&lt;P&gt;Is there a way to (force) standardise the colour scale across the heat maps?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 10:10:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771099#M244644</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2021-09-29T10:10:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sandarizing colour scale in heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771101#M244646</link>
      <description>&lt;P&gt;Have you tried using the COLORGROUP variable?&lt;/P&gt;
&lt;P&gt;See &lt;A href="https://www.lexjansen.com/sesug/2017/RIV-138.pdf" target="_self"&gt;this&lt;/A&gt;&amp;nbsp;and &lt;A href="https://www.pharmasug.org/proceedings/2021/DV/PharmaSUG-2021-DV-078.pdf" target="_self"&gt;this&lt;/A&gt; examples.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 10:23:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771101#M244646</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2021-09-29T10:23:12Z</dc:date>
    </item>
    <item>
      <title>Re: Sandarizing colour scale in heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771105#M244649</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/16961"&gt;@ChrisNZ&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Very hepful indded.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I only needed to read the documentation in more details, I found the rattrmap option seems to give control over how the colours are assigned.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myrattrmap;
retain id "myID";
length min $ 5 max $ 5;
input min $ max $ color $ altcolor $;
datalines;
_min_ 4    purple purple
4    6   gold   gold
6   _max_ green  green
;
run;

proc sgplot data=have rattrmap=myrattrmap;
   heatmapparm x=a y=i colorresponse=o / rattrid=myID outline discretex colormodel=ThreeColorRamp;
   text x=a y=i text=o / textattrs=(size=10pt) strip;
   by L ;
   gradlegend;
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Sep 2021 10:30:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771105#M244649</guid>
      <dc:creator>ammarhm</dc:creator>
      <dc:date>2021-09-29T10:30:03Z</dc:date>
    </item>
    <item>
      <title>Re: Sandarizing colour scale in heatmap</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771140#M244671</link>
      <description>&lt;P&gt;How about this one ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Data have;
call streaminit(12345678);
	do a= 1 to 3;
		do i=1 to 5;
			L=1;
			o=floor(rand('Uniform')*10);
			output;
		end;
	output;
	end;


	do a= 1 to 3;
		do i=1 to 5;
			L=2;
			o=floor(rand('Uniform')*5)+2; 
			output;
		end;
	output;
	end;

run;


proc sql noprint;
select min(o),max(o) into :min,:max from want;
quit;


proc template;
  define statgraph cal_heatmap;
    begingraph ;
	  entrytitle "xxxxxxxxxx";
	  rangeattrmap name="rmap";
        range &amp;amp;min- &amp;amp;max / rangecolormodel=ThreeColorRamp;		

	  endrangeattrmap;
	  rangeattrvar attrmap="rmap" attrvar=cvar var=o;
	  layout overlay ;
	    heatmapparm x=a y=i colorresponse=cvar/ name="heatmap" xgap=1 ygap=1;
		scatterplot x=a y=i/ MARKERCHARACTER=o  markerattrs=(size=20pt) ;

		*continuouslegend "heatmap" ;
	  endlayout;
	endgraph;
  end;
run;

proc sgrender data=have template=cal_heatmap;
by l;
run;

&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1632923961824.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64222i501478DF3DF83ED9/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1632923961824.png" alt="Ksharp_0-1632923961824.png" /&gt;&lt;/span&gt;&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="Ksharp_1-1632923980346.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64223iFA70F761D45BA043/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_1-1632923980346.png" alt="Ksharp_1-1632923980346.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 29 Sep 2021 13:59:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Sandarizing-colour-scale-in-heatmap/m-p/771140#M244671</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-29T13:59:42Z</dc:date>
    </item>
  </channel>
</rss>

