BookmarkSubscribeRSS Feed
msrenee1984
Obsidian | Level 7

Hello , I wanted to know if there is a way to add column and row totals to my heat map?

 

ods graphics / width=12cm height=50cm;
title "apples eaten Per Facility by Year ";
title2 "apple Counts (N=5952)";
/* basic heat map */
proc sgplot data=freqout; /*temp*/
heatmap x=year y=facility / colorresponse=Count
discretex discretey colormodel=(green redTwoColorRamp)outline ;
yaxis label='Facility Name' valueattrs=(size=4pt) labelattrs=(size=8pt);
xaxis label='Calender Year' valueattrs=(size=5pt) labelattrs=(size=5pt);
text x=year y=facility text=count text=total / textattrs=(size=3pt) ;
run;

1 REPLY 1
MarciaS
SAS Employee

Hi @msrenee1984 

 

You can use the XAXISTABLE and YAXISTABLE statements in PROC SGPLOT to place the row and column totals on the graph.

Below is a sample showing how to do this with your PROC SGPLOT code. 

data freqout; /* Sample data */
  input year facility count;
  datalines;
2021 1 40
2021 2 30
2022 1 10
2022 2 30
2023 1 30
2023 2 40
;
run;
proc sgplot data=freqout noautolegend; /*temp*/
  heatmap x=year y=facility / colorresponse=Count
  discretex discretey colormodel=(green redTwoColorRamp)outline ;
  yaxis label='Facility Name' valueattrs=(size=8pt) labelattrs=(size=8pt);
  xaxis label='Calender Year' valueattrs=(size=8pt) labelattrs=(size=5pt);
  text x=year y=facility text=count / textattrs=(size=8pt) ;
  yaxistable count /position=right valueattrs=(size=8pt) nolabel;
  xaxistable count /position=top valueattrs=(size=8pt) nolabel;
run;

Hope this helps.

 

Regards,

Marcia

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 1 reply
  • 356 views
  • 0 likes
  • 2 in conversation