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

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;
1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

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.

View solution in original post

3 REPLIES 3
FreelanceReinh
Jade | Level 19

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.

genemroz
Quartz | Level 8

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

FreelanceReinh
Jade | Level 19

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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 3 replies
  • 480 views
  • 0 likes
  • 2 in conversation