BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ihsan-Mahdi
Quartz | Level 8

Can someone please explain  this white column in the middle of the graph:

PedalBikeHeatMapYearMonth.png

I have no missing data btw!

Thank you 🙂

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

Add the DISCRETEX option to the HEATMAP statement:

title "Injury Frequency by Year and Month";

proc sgplot data=sample;
heatmap
  x=year y=MonthName /
  colorresponse=COUNT
  discretex
;
by InjuryType;
xaxis label="Year" values=(2020 2021 2022 2023 2024);
/* Character Y-axis preserves names; order guaranteed by sorting */
yaxis label="Month of Year" discreteorder=data;
run;

View solution in original post

5 REPLIES 5
Ihsan-Mahdi
Quartz | Level 8

I apologize. There were typos in my earlier messages. Please discard and use set and code in this message.

set:

data sample (compress=binary);
      INPUT injurytype $ year  MonthName $   Month   Count ; 
  
      DATALINES;
 
pedalbike 2020 Jan 1 19
pedalbike 2020 Feb 2 23
pedalbike 2020 Mar 3 34
pedalbike 2020 Apr 4 59
pedalbike 2020 May 5 67
pedalbike 2020 Jun 6 106
pedalbike 2020 Jul 7 108
pedalbike 2020 Aug 8 110
pedalbike 2020 Sep 9 67
pedalbike 2020 Oct 10 64
pedalbike 2020 Nov 11 26
pedalbike 2020 Dec 12 23
pedalbike 2021 Jan 1 13
pedalbike 2021 Feb 2 16
pedalbike 2021 Mar 3 47
pedalbike 2021 Apr 4 59
pedalbike 2021 May 5 76
pedalbike 2021 Jun 6 69
pedalbike 2021 Jul 7 90
pedalbike 2021 Aug 8 75
pedalbike 2021 Sep 9 55
pedalbike 2021 Oct 10 37
pedalbike 2021 Nov 11 19
pedalbike 2021 Dec 12 16
pedalbike 2022 Jan 1 11
pedalbike 2022 Feb 2 23
pedalbike 2022 Mar 3 33
pedalbike 2022 Apr 4 43
pedalbike 2022 May 5 50
pedalbike 2022 Jun 6 73
pedalbike 2022 Jul 7 89
pedalbike 2022 Aug 8 67
pedalbike 2022 Sep 9 69
pedalbike 2022 Oct 10 52
pedalbike 2022 Nov 11 17
pedalbike 2022 Dec 12 5
pedalbike 2023 Jan 1 12
pedalbike 2023 Feb 2 20
pedalbike 2023 Mar 3 38
pedalbike 2023 Apr 4 45
pedalbike 2023 May 5 80
pedalbike 2023 Jun 6 76
pedalbike 2023 Jul 7 98
pedalbike 2023 Aug 8 89
pedalbike 2023 Sep 9 86
pedalbike 2023 Oct 10 40
pedalbike 2023 Nov 11 26
pedalbike 2023 Dec 12 22
pedalbike 2024 Jan 1 21
pedalbike 2024 Feb 2 15
pedalbike 2024 Mar 3 25
pedalbike 2024 Apr 4 48
pedalbike 2024 May 5 67
pedalbike 2024 Jun 6 82
pedalbike 2024 Jul 7 92
pedalbike 2024 Aug 8 100
pedalbike 2024 Sep 9 89
pedalbike 2024 Oct 10 38
pedalbike 2024 Nov 11 20
pedalbike 2024 Dec 12 17
 
;
 
run;
 
Code:

ods html close;
ods html;
proc sgplot data=sample;

heatmap x=year y=MonthName /
colorresponse=COUNT ;

by InjuryType;

xaxis label="Year" values=(2020 2021 2022 2023 2024);

/* Character Y-axis preserves names; order guaranteed by sorting */
yaxis label="Month of Year" discreteorder=data;

title "Injury Frequency by Year and Month";
run;

Kurt_Bremser
Super User

Add the DISCRETEX option to the HEATMAP statement:

title "Injury Frequency by Year and Month";

proc sgplot data=sample;
heatmap
  x=year y=MonthName /
  colorresponse=COUNT
  discretex
;
by InjuryType;
xaxis label="Year" values=(2020 2021 2022 2023 2024);
/* Character Y-axis preserves names; order guaranteed by sorting */
yaxis label="Month of Year" discreteorder=data;
run;
Ihsan-Mahdi
Quartz | Level 8
Worked like a charm! Thank you so much 🙂
Ksharp
Super User

An alternative way is using HEATMAPPARM statement:

 

proc sgplot data=sample;
heatmapparm x=year y=MonthName colorresponse=COUNT ;

by InjuryType;

xaxis label="Year";

/* Character Y-axis preserves names; order guaranteed by sorting */
yaxis label="Month of Year" discreteorder=data;

title "Injury Frequency by Year and Month";
run;

屏幕截图 2026-03-10 170214.png

Catch up on SAS Innovate 2026

Dive into keynotes, announcements and breakthroughs on demand.

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

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 448 views
  • 6 likes
  • 3 in conversation