Hi,
I'm building a PLOT SGPLOT HEATMAP with TEXT to label the values. I need anywhere the value is zero for the text to be white or omitted without dropping the row from the heatmap.
The values were originally missing, but I made them zero so that the row did not get dropped (when all were missing values).
Any help or guidance is appreciated. SAS EG version 7.1 SAS 9.4M4 (I think)
Data Table : Ordering
Delay | WK_ENDING_DT | Sum_Nbr | Nbr_Revised |
AAA | 22Jun2018 | 252.803 | 253 |
AAA | 29Jun2018 | 2.3331 | 2 |
AAA | 06Jul2018 | 635.9472 | 636 |
AAA | 13Jul2018 | 0 | |
BBB | 22Jun2018 | 809.6699 | 810 |
BBB | 29Jun2018 | 0 | |
BBB | 06Jul2018 | 54.153 | 54 |
BBB | 13Jul2018 | 0 | |
CCC | 22Jun2018 | 14420.7365 | 14,421 |
CCC | 29Jun2018 | 1401.0775 | 1,401 |
CCC | 06Jul2018 | 11280.8229 | 11,281 |
CCC | 13Jul2018 | 4882.6366 | 4,883 |
DDD | 22Jun2018 | 70.7879 | 71 |
DDD | 29Jun2018 | 25.713 | 26 |
DDD | 06Jul2018 | 0 | |
DDD | 13Jul2018 | 310.3668 | 310 |
EEE | 22Jun2018 | 0 | |
EEE | 29Jun2018 | 0 | |
EEE | 06Jul2018 | 27.63 | 28 |
EEE | 13Jul2018 | 0 | |
FFF | 22Jun2018 | 0 | |
FFF | 29Jun20 | 0 | |
FFF | 06Jul2018 | 0 | |
FFF | 13Jul2018 | 0 |
proc sgplot data=work.ordering noautolegend noborder nowall noopaque ;
heatmap x=WK_ENDING_DT y=DELAY / weight=nbr_revised colormodel=(white white yellow orange lightred)
outline discretex discretey y2axis;
text x=wk_ending_dt y=delay text=nbr_revised / textattrs=(size=11pt family='helvetica'
style=normal color=black) strip fillattrs=(color=white );
yaxis display=(noticks nolabel novalues ) reverse;
y2axis labelattrs=(size=14pt family="Arial Narrow" )labelpos=center display=(noticks nolabel) reverse
valueattrs=(size=11pt family='arial narrow' style=normal color=black) fitpolicy=none;
xaxis label="Week Ending Date" labelattrs=(size=14pt family='arial narrow' style=normal )
labelpos=center display=(noticks);
format wk_ending_dt date7.;
TITLE h=12pt bold BL=YES BCOLOR=white c=black j=left f=arial "Make my Zeros Turn White";
run;
Output: I need zeros to not show up in the chart output.
Try this:
1. In the data, create a new variable
TEXTCOLOR = (NBr_Revised > 0);
2. On the TEXT statement in SGPLOT, use
COLORRESPONSE=TextColor ColorModel=(White Black);
Try this:
1. In the data, create a new variable
TEXTCOLOR = (NBr_Revised > 0);
2. On the TEXT statement in SGPLOT, use
COLORRESPONSE=TextColor ColorModel=(White Black);
That worked great! I appreciate the help.
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.