BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
mifta
Calcite | Level 5

I want to change the color ramp of my heatmap plot. I make a heatmap plot using a graphical template language. My response variable is in percentage form. So, I want to make the colormodel represent the value between 0 to 100 percent, blue color for low percentage (0% to 10%), white color for 10% to 20%, and red color for more than 20%. But my response variable (colorresponse) is range between 0 to around 20 percent, which caused different output from what I want. The color range follow the response variable's range (0 to 20%). Here is the code I've tried.

 

proc template;
define statgraph training;
begingraph /DESIGNHEIGHT=550px DESIGNWIDTH=650px;
entrytitle 'Heatmap of Digit Check';
layout overlay /yaxisopts=(label="Date" tickvalueattrs=(size=8pt)) xaxisopts=(label="Last Digit" tickvalueattrs=(size=8pt));
heatmapparm y=day x=ld colorresponse=percent / display=all name='percent' colormodel=(blue white red);
scatterplot x=sbp_ld y=day /markercharacter=percent markercharacterattrs=(size=8);
continuouslegend 'percent';
endlayout;
endgraph;
end;
run;

 

proc sgrender data=digit_check template=training;
run;

 

Here is the result.

Doc1-page0001.jpg

 Could anyone help me on this? Thank you for any help you can offer.

 

Regards,

Mifta

1 ACCEPTED SOLUTION
2 REPLIES 2
mifta
Calcite | Level 5
Hi Ksharp, Thank you for this. I already followed the steps in the articles you sent, but I found a problem when trying to use the custom color ramp in colormodel= option in the hetmapparm. But thankfully it already resolved. Here is the full script that I use, in case other people need it.

proc template;
define statgraph training;
begingraph/DESIGNHEIGHT=500px DESIGNWIDTH=550px;
rangeattrmap name="ResponseRange";
range MIN - 10 / rangeColorModel=(blue lightblue);
range 10 < - 20 / rangeColorModel=(lightblue white lightred);
range 20 < - MAX / rangeColorModel=(lightred red);
endrangeattrmap;
rangeattrvar var=percent /* specify response variable in data set */
attrmap="ResponseRange" /* specify custom color ramp */
attrvar=RangeVar; /* alias for this variable/ramp combination */
entrytitle "Heat Map";
layout overlay /yaxisopts=(label="Employee" tickvalueattrs=(size=8pt)) xaxisopts=(label="Last Digit" tickvalueattrs=(size=8pt));
heatmapparm y=employee x=last_digit colorresponse=RangeVar / display=all name='percent';
scatterplot x=last_digit y=employee /markercharacter=percent markercharacterattrs=(size=6.5);
continuouslegend 'percent' / title='Percentage';
endlayout;
endgraph;
end;
run;

Regards,
Mifta

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 456 views
  • 2 likes
  • 2 in conversation