Hello everybody,
Here is my code:
proc template; /* basic heat map with continuous color ramp */
define statgraph heatmap;
dynamic _TRD_EVENT_tm _TRD_EVENT_dt _price _T; /* dynamic variables */
begingraph;
entrytitle _T; /* specify title at run time (optional) */
layout overlay;
heatmapparm x=_TRD_EVENT_tm y=_TRD_EVENT_dt colorresponse=_price / /* specify variables at run time */
name="heatmap" primary=true
xbinaxis=false ybinaxis=false; /* tick marks based on range of X and Y */
continuouslegend "heatmap";
endlayout;
endgraph;
end;
run;
proc sgrender data=sampledata05 template=Heatmap;
dynamic _TRD_EVENT_tm='Time' _TRD_EVENT_dt='Date' _Price='Price' _T="Basic Heat Map";
run;
And, here is the log file:
WARNING: The heatmapparm statement named 'heatmap' will not be drawn because one or more of the
required arguments were not supplied.
WARNING: CONTINUOUSLEGEND statement references a plot named (heatmap) that is not assigned to any
plot. The name will be ignored.
All variables are numeric.
How can I fix that?
Thanks in advance.
I am NOT an expert with either PROC TEMPLATE or PROC SGRENDER, but tried your code anyhow.
It wouldn't run unless I removed all of the comments. You didn't provide your data so I couldn't complete the test (i.e., run PROC SGRENDER), but the PROC TEMPLATE ran without error. I ran:
proc template; define statgraph heatmap; dynamic _TRD_EVENT_tm _TRD_EVENT_dt _price _T; begingraph; entrytitle _T; layout overlay; heatmapparm x=_TRD_EVENT_tm y=_TRD_EVENT_dt colorresponse=_price / xbinaxis=false ybinaxis=false; continuouslegend "heatmap"; endlayout; endgraph; end; run;
Art, CEO, AnalystFinder.com
Respected #art297, I appreciate your support.
However, warnings are still alive!
I attach a sample of my dataset.
Thanks in advance.
It looks like you copied the code from my blog post "Creating a basic heat map in SAS". The post includes sample data and output.
I assume the problem is the data, not the template. In the data that you attached, the TRD_EVENT_TM has the constant value 1/01/1900 and the variable TRD_EVENT_DT appears to have only two dates. You also have multiple repeated values. The HEATMAPPARM statement is expecting a regular grid of values with a unique response value for each cell.
Yes @Rick_SAS, I use your code and thank you for everything you’ve done.
I work with big data and the sample, which I attached, has a time and date variables that are not constant.
I use @art297's rewritten codes, although there is an error:
ERROR: Unable to restore 'Heatmapparm' from template store!
Thanks in advance.
I agree with @Rick_SAS .. your variables don't match the one's you specified. Also, your time variable is a datetime variable.
The following worked for me:
proc import datafile='/folders/myfolders/test.xls' dbms=xls out=sampledata05 replace; sheet=test; run; data sampledata05; set sampledata05; format time time5.; time=timepart(trd_event_tm); run; proc template; define statgraph heatmap; dynamic _TRD_EVENT_tm _TRD_EVENT_dt _price _T; begingraph; entrytitle _T; layout overlay; heatmapparm x=_TRD_EVENT_tm y=_TRD_EVENT_dt COLORRESPONSE=_price/ name='heatmapparm' xbinaxis=false ybinaxis=false; continuouslegend "heatmapparm" / location=outside valign=bottom; endlayout; endgraph; end; run; proc sgrender data=sampledata05 template=Heatmapparm; dynamic _TRD_EVENT_tm='time' _TRD_EVENT_dt='TRD_EVENT_dt' _Price='Price' _T="Basic Heat Map"; run;
Art, CEO, AnalystFinder.com
There was an error in the datastep I used, but the code produced a map (without any errors). The correct datastep should have been:
data sampledata05; set sampledata05; format time time5.; time=timepart(trd_event_tm); run;
I corrected it in the post as well. However, it doesn't answer the question of why you are getting an error, as mine ran correctly whether it was corrected or not.
I'll have to leave it to someone like @Rick_SAS who is more familiar with the technique than I am. Sorry I couldn't be of more help.
Art, CEO, AnalystFinder.com
That's the error message you get if you can't overwrite a template. I encounter this sometimes when I am running two copies of SAS: The first copy locks the template files and the second can't overwrite.
The easiest thing to do it to exit all copies of SAS and then restart one copy.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.