Creating Heat Maps
/****************************************************************/
/* S A S S A M P L E L I B R A R Y */
/* */
/* NAME: GRHEAT */
/* TITLE: Creating Heat Maps */
/* PRODUCT: IML */
/* DATA: */
/* */
/* SUPPORT: Rick Wicklin UPDATE: SEP 2013 */
/* REF: */
/* MISC: */
/* */
/****************************************************************/
proc iml;
use Sashelp.Class;
read all var _NUM_ into Students[c=varNames r=Name];
close Sashelp.Class;
/* sort data in descending order according to Age and Height */
call sortndx(idx, Students, 1:2, 1:2);
Students = Students[idx,];
Name = Name[idx];
/* standardize each column */
call HeatmapCont(Students) scale="Col"
xvalues=varNames yvalues=Name title="Student Data";
use Sashelp.Cars;
read all var _NUM_ into Y[c=varNames];
close Sashelp.Cars;
corr = corr(Y);
/* You can visualize the correlations as a continous heat map:
call HeatmapCont(corr) xvalues=varNames yvalues=varNames;
Alternatively, bin the values into five categories, as follows: */
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";