BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaalNavestad
Pyrite | Level 9

I want to control the label for the heatmap description. heatmap.PNG

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Jay54
Meteorite | Level 14

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;

GradLegend.png

View solution in original post

6 REPLIES 6
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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:

http://support.sas.com/documentation/cdl/en/grstatgraph/65377/HTML/default/viewer.htm#p0gf6kx2u9fewe...

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).

 

 

 

PaalNavestad
Pyrite | Level 9

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 producedwith_keylegend.PNG

AS can be seen this makes the descriptive legend disappear. The same problem occurs when using colorresponse in a scatter staement.

PaalNavestad
Pyrite | Level 9

Hi again, and thanks for the tip of using GTL. That works but is a bit more cumbersome:-)

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.  

Jay54
Meteorite | Level 14

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;

GradLegend.png

PaalNavestad
Pyrite | Level 9

Thanks a lot. Works like a dream. Did not think tio look for a separate chapter in the documentation.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 6 replies
  • 2047 views
  • 1 like
  • 3 in conversation