Esteemed Graphics Gurus:
I'm trying follow Rick Wicklin's blog posting entitled "Create a discrete heatmap with PROC SGPLOT".
I'm having a problem with getting the right color mapping. Below is simplified version of the code that demonstrates the problem. Observations where x=6 through x=10 are expected to display as "lightgreen" but display as brown instead.
Been scratching my head over this for awhile and finally decided to seek expert advice.
Thanks,
Gene
data XYK;
input x y k;
datalines;
1 1 1
2 1 2
3 1 3
4 1 4
5 1 5
6 1 6
7 1 7
8 1 8
9 1 9
10 1 10
11 1 11
12 1 12
13 1 13
14 1 14
15 1 15
;
proc format;
value kformat
1 = "1 Camera"
2 = "2 Cameras"
3 - 5 = "3-5 Cameras"
6 - 10 = "6-10 Cameras"
11 - high = ">10 Cameras";
run;
data order;
length value $11 FillColor $15;
input raw FillColor;
Value=put(raw, kformat.);
retain ID 'SortOrder'
Show 'AttrMap';
datalines;
1 verylightred
2 yellow
5 verylightgreen
7 lightgreen
11 moderategreen
;
run;
ods graphics on/ width=6.4in height=6.4in imagemap;
proc sgplot data=XYK aspect=1 dattrmap=order;
title height=12pt "HeatMap Color Mapping Problem";
format k kformat.;
heatmapparm x=x y=y colorgroup=k/ attrid=SortOrder;
gradlegend/title='Number of Cameras';
xaxis grid min=0 max=20 label='X axis';
yaxis grid min=0 max=10 label='Y axis';
keylegend;
run;
Hello @genemroz,
@genemroz wrote:
Esteemed Graphics Gurus:
I'm trying follow Rick Wicklin's blog posting entitled "Create a discrete heatmap with PROC SGPLOT".
I'm having a problem with getting the right color mapping. Below is simplified version of the code that demonstrates the problem. Observations where x=6 through x=10 are expected to display as "lightgreen" but display as brown instead.
As a graphics non-guru I think the issue is just the truncation of "6-10 Cameras" (length 12) due to the insufficient length specification $11 for variable VALUE in dataset ORDER.
Hello @genemroz,
@genemroz wrote:
Esteemed Graphics Gurus:
I'm trying follow Rick Wicklin's blog posting entitled "Create a discrete heatmap with PROC SGPLOT".
I'm having a problem with getting the right color mapping. Below is simplified version of the code that demonstrates the problem. Observations where x=6 through x=10 are expected to display as "lightgreen" but display as brown instead.
As a graphics non-guru I think the issue is just the truncation of "6-10 Cameras" (length 12) due to the insufficient length specification $11 for variable VALUE in dataset ORDER.
Solution Accepted! I knew this was going to happen The solution to these kind of issues is often obvious to someone looking at the code with a fresh set of eyes.
Thanks for your help--you are now a graphics guru,
Gene
@genemroz wrote:
Thanks for your help--you are now a graphics guru,
Thanks :-), but for that title I would probably need to know (among other things) how SAS picked the brown color for the unknown category ...
Actually the length specification for VALUE in the data step could be omitted because VALUE would then inherit the length 12 of format KFORMAT. (Only the order of variables would change.)
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.