Using SAS9.4
I have my code below. I am trying to adjust the values on the second yaxis. Currently, the count is displayed there, which I want, but I would like to adjust the count to display more numbers. Ideally, I would like to display 1 to 15 by 1 but I have not been able to accomplish this. Any help would be appreciated. Thank you
proc sgplot data=heatmap_data;
heatmapparm x=score y=Average_grade colorresponse=Count / colormodel=(blue gray red) tip=(Count);
xaxis values=(1 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0);
yaxis values=(1.5 2.0 2.5 3.0 3.5 4.0);
gradlegend / title="Count" integer;
run;
First thing is to change some thinking. Those numbers that appear next to the color response are not axis values but response values. So no statements that affect axis appearance will influence them.
The only thing I know to change the values that appear in the color response is to define a Range attribute data set with min max values appearing with color options. The min value for each range plus the largest max value then appears on the color response area.
If you want a continuous ramp of colors then the end point values (the max of the lower and the min of the next) would have the same color value.
Since you want to go from 2 to 15 displayed values that means your range attribute set would need 15 min/max pairs. Do you want to add that much work?
It might be possible to create an annotate data set but that is likely going to involve a LOT of x,y coordinate guessing to display the values that do not appear on the response ranges. Which work would have to be repeated.
Here is an example:
data have;
call streaminit(123);
do x=1 to 5;
do y=1 to 5;
count=rand('integer',1,15);output;
end;
end;
run;
data rattrmap2;
id='id';
input min $ max $ colormodel1 $ colormodel2 $ ;
cards;
1 2 CXEFF3FF CXBDD7E7
2 3 CXBDD7E7 CX6BAED6
3 4 CX6BAED6 CX3182BD
4 5 CX3182BD CX08519C
5 6 CX08519C CXF7F7F7
6 7 CXF7F7F7 CXCCCCCC
7 8 CXCCCCCC CX969696
8 9 CX969696 CX636363
9 10 CX636363 CX252525
10 11 CX252525 CXFEE5D9
11 12 CXFEE5D9 CXFCAE91
12 13 CXFCAE91 CXFB6A4A
13 14 CXFB6A4A CXDE2D26
14 15 CXDE2D26 CXA50F15
15 16 CXA50F15 red
;
proc sgplot data=have rattrmap=rattrmap2;
heatmapparm x=x y=y colorresponse=Count / tip=(Count) rattrid=id;
xaxis integer;
yaxis integer;
/* gradlegend / title="Count" integer;*/
run;
Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.
Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.
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.