I want to control the label for the heatmap description.
The label I want to be able to control is circled in blue in the picture.
Here is the code that produces the picture:
ods graphics on/width= 400 px height=300 px;
proc sgplot data=sashelp.cars;
heatmap x=msrp y=horsepower;
run;
The heatmap feature and other features that creates color by a statistics seem to default the description to the correct statistical name for this in English. That is mostly OK, but sometimes you want to control the description or remove.
Can anybody tell me if it is possble and how I can change this?
With HeatMap, you get a "Gradient Legend", not a "Discrete Legend". Use the following code to customize the legend:
ods graphics on/width= 400 px height=300 px; proc sgplot data=sashelp.cars; heatmap x=msrp y=horsepower; gradlegend / title='New Label'; run;
You should be able to change that parts label and things by naming the graph and putting in the keylegend options:
proc sgplot data=sashelp.cars; heatmap x=msrp y=horsepower / name='hm'; keylegend 'hm' / title="Something"; run;
Now for some reason my SAS is not recognising heatmap as valid - could just be my instal, so can't check that. But you should be able to change the legend paratmers, here is a GTL example also:
And there are many more over at the Graphs blog:
http://blogs.sas.com/content/graphicallyspeaking/?s=heatmap
(Note I filtered it, there are plenty of discussions on all kinds of things there - should be top of the list to check for any graph related items).
Hi, thanks for your answer. Unfotunatly it does not work. The reason you can't test is probably that you do not have 9.4M3 installed. These functions came with that release.
running this code
ods graphics on /width=500 px height= 300 px;
proc sgplot data=sashelp.cars;
heatmap x=msrp y=horsepower / name='hm';
keylegend 'hm' / title="Something";
run;
The following is produced
AS can be seen this makes the descriptive legend disappear. The same problem occurs when using colorresponse in a scatter staement.
Hi again, and thanks for the tip of using GTL. That works but is a bit more cumbersome:-)
Well, sgplot actually generates the gtl behind the scenes. Simply put:
proc sgplot data=abc tmplout="c:\temp.txt"; ... run;
The tmplout indicates to SAS to store the underlying GTL code to a file. . You can then take this template code and modify it. Starting with GTL (and finding out options) this is a great way to learn and get code quickly. GTL is more flexible than sgplot, you can pass in dynamics, do conditional code, etc.
With HeatMap, you get a "Gradient Legend", not a "Discrete Legend". Use the following code to customize the legend:
ods graphics on/width= 400 px height=300 px; proc sgplot data=sashelp.cars; heatmap x=msrp y=horsepower; gradlegend / title='New Label'; run;
Thanks a lot. Works like a dream. Did not think tio look for a separate chapter in the documentation.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.