☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Quartz | Level 8

## Incorrect color mapping

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;
xaxis grid min=0 max=20 label='X axis';
yaxis grid min=0 max=10 label='Y axis';
keylegend;
run;``````
1 ACCEPTED SOLUTION

Accepted Solutions
Jade | Level 19

## Re: Incorrect color mapping

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.

3 REPLIES 3
Jade | Level 19

## Re: Incorrect color mapping

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.

Quartz | Level 8

## Re: Incorrect color mapping

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

Jade | Level 19

## Re: Incorrect color mapping

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

Discussion stats
• 3 replies
• 265 views
• 0 likes
• 2 in conversation