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