Data visualization with SAS programming

Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

Accepted Solution Solved
Reply
Contributor
Posts: 32
Accepted Solution

Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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?


Accepted Solutions
Solution
‎11-28-2016 01:49 AM
SAS Super FREQ
Posts: 1,141

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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


All Replies
Super User
Super User
Posts: 7,720

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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

 

 

 

Contributor
Posts: 32

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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.

Contributor
Posts: 32

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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

Super User
Super User
Posts: 7,720

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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.  

Solution
‎11-28-2016 01:49 AM
SAS Super FREQ
Posts: 1,141

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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

Contributor
Posts: 32

Re: Changing the label for the colorrange description in for instanace Heatmap in SAS Gplot

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

☑ This topic is solved.

Need further help from the community? Please ask a new question.

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