<?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: Customise Heatmap for Categorical variables in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803473#M22692</link>
    <description>&lt;P&gt;Show the code you are using for your heatmap. Since there enough options involved I don't want to spend time trying to guess which approach you started with. The options you have chosen may well influence other options needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A description of what color you want where may help as well. There are multiple ways to assign colors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example data that will run your heatmap would be a good idea. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Mar 2022 23:16:10 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-03-22T23:16:10Z</dc:date>
    <item>
      <title>Customise Heatmap for Categorical variables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803441#M22690</link>
      <description>Hi all. I have a data set, with 3 variables&lt;BR /&gt;ID Diet Day&lt;BR /&gt;1 0 0&lt;BR /&gt;1 0 2&lt;BR /&gt;1 1 3&lt;BR /&gt;2 1 1&lt;BR /&gt;3 0 1&lt;BR /&gt;4 1 0&lt;BR /&gt;5 0 2&lt;BR /&gt;5 2 2&lt;BR /&gt;&lt;BR /&gt;My diet variable means a person (ID) could have had Diet 1 on a given day, but also a mix of 1 and 2 (i.e. 2) on a given day. I have generated a heatmap to visualise this, but as you can see the day variable is different for all IDs. Some IDs have observations for day 0 and some only for day 2. So when I generate my heatmap (proc sgplot with the heatmap and coulourgroup=), I see the white gaps inbetween. I am looking for a way in which I can assign a colour to those white spaces inbetween the tiles in SAS. For example I was ro assigna colour to a white space in which ID 5 has not data for day 0. I could appreciate any help</description>
      <pubDate>Tue, 22 Mar 2022 19:21:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803441#M22690</guid>
      <dc:creator>Giftable</dc:creator>
      <dc:date>2022-03-22T19:21:57Z</dc:date>
    </item>
    <item>
      <title>Re: Customise Heatmap for Categorical variables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803465#M22691</link>
      <description>&lt;P&gt;[&amp;nbsp; I have moved this post to 'Graphics Programming' board.&amp;nbsp; ]&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 22:09:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803465#M22691</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2022-03-22T22:09:34Z</dc:date>
    </item>
    <item>
      <title>Re: Customise Heatmap for Categorical variables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803473#M22692</link>
      <description>&lt;P&gt;Show the code you are using for your heatmap. Since there enough options involved I don't want to spend time trying to guess which approach you started with. The options you have chosen may well influence other options needed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A description of what color you want where may help as well. There are multiple ways to assign colors&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example data that will run your heatmap would be a good idea. Instructions here: &lt;A href="https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712" target="_blank"&gt;https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-data-AKA-generate/ta-p/258712&lt;/A&gt; will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the &amp;lt;&amp;gt; icon or attached as text to show exactly what you have and that we can test code against.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Mar 2022 23:16:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803473#M22692</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-03-22T23:16:10Z</dc:date>
    </item>
    <item>
      <title>Re: Customise Heatmap for Categorical variables</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803535#M22694</link>
      <description>&lt;P&gt;Well, WHITE is a color, but I guess you are saying you want a non-white color for the missing cells.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I assume your current program looks like the following. Notice that I am using the HEATMAPPARM statement, which assumes the data are presummarized:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Have;
input ID Diet Day;
datalines;
1 0 0
1 0 2
1 1 3
2 1 1
3 0 1
4 1 0
5 0 2
5 2 3
;
title "A Heat Map";
proc sgplot data=Have;
heatmapparm x=Day y=ID colorgroup=Diet; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To add color to the missing cells, you need to explicitly add the coordinates of the cells and use a missing value for the DIET variable. THe following code creates a grid of missing values and then merges the data with the grid so that your observed values overwrite the missing values:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;/* create grid of missing values */
data Missing;
do ID = 1 to 5;
   do Day = 0 to 3;
      Diet = .;
      output;
   end;
end;
run;
/* merge with observed data */
data Combine;
merge Missing Have;
by ID Day;
run;
/* for consistent results, you might want to sort by the response var */
proc sort data=Combine;
by Diet;
run;

title "A Heat Map";
proc sgplot data=Combine;
heatmapparm x=Day y=ID colorgroup=Diet / outline; 
keylegend;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The color of the missing cells is the&amp;nbsp;&lt;SPAN&gt;GraphMissing style element in the current ODS style.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Mar 2022 10:31:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Customise-Heatmap-for-Categorical-variables/m-p/803535#M22694</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2022-03-23T10:31:25Z</dc:date>
    </item>
  </channel>
</rss>

