Creating a heat map in SAS

I want to create a heat map in SAS. I have a large dataset of x, y coordinates and that's it. From reading to everything, I need to create a "score" for the coordinates using something like this:

 proc kde data=dataSet;
     bivar X Y / out=outputDataSet;
 run;

      

Next, I need to create a template for the heatchart - I found this example code, but I'm not sure what everything does:

proc template;
   define statgraph heatmapparm;
     begingraph;
       layout overlay;
         heatmapparm x=value1 y=value2 colorresponse=count /
             name="heatmapparm" xbinaxis=false ybinaxis=false;
         continuouslegend "heatmapparm" / location=outside valign=bottom;
       endlayout;
     endgraph;
end;
run;

      

My guess is that I need to insert my variables at the x and y spots and the counter at the colorresponse location, and then use code like this to get a hot map:

proc sgrender data=outputDataSet template=heatmapparm;
run;

      

This code results in an error message and no graph output because it is "missing argument". Any help would be great. Thank!

+3


source to share


1 answer


Rick Wicklin explains this well on his Loop Loop blog .

You should find a tutorial on Graph Pattern Language (GTL) like Sanjay Matanj (lead developer of ODS Graphics system including GTL). He wrote a book on this topic, or you can read his papers, such as this introduction .

Basically, yes, you should fill x = and y = with your x / y variables, colorresponse = with a variable that defines the score (how to do it in red / blue to do this).



Here's an example. Here we are using dynamic variables

, which means you can define the corresponding variable in a step SGRENDER

. Rick shows this on his blog, I'm using a slightly simplified version. You can probably use PROC TEMPLATE

it exactly as it is, just changing SGRENDER to refer to your dataset and your variables. The dataset test

is the data just taken that will generate an interesting heat map.

proc template;
   define statgraph heatmapparm;
    dynamic _X _Y _Z;
     begingraph;
       layout overlay;
         heatmapparm x=_X y=_Y colorresponse=_Z/
             name="heatmapparm" xbinaxis=false ybinaxis=false;
         continuouslegend "heatmapparm" / location=outside valign=bottom;
       endlayout;
     endgraph;
  end;
run;

data test;
  call streaminit(7);
  do x = 1 to 10;
    do y = 1 to 10;
      count_var = rand('Normal',(x+y)/2);
      output;
    end;
  end;
run;


proc sgrender data=test template=heatmapparm;
dynamic _X='x' _Y='y' _Z='count_var';
run;

      

+3


source







All Articles