I'm creating a heatmap with discrete X and discrete Y axis. The discrete Y axis is numerical (BEST12.) but yaxis discreteorder=formatted and discreteorder=unformatted are both sorting the variable lexigraphicly.
Expected: 1 2 3 4 5 ... 10 11 12 ... 20 Actual: 1 10 11 ... 2 20 21 ....
How do I force a numerical sort order?
proc sgplot data=Heatmap;
yaxis discreteorder=formatted;
heatmap x=Battalion y=StationArea / name='HeatMap' discretey discretex
colorresponse=arrive_seconds colorstat=mean;
gradlegend 'HeatMap';
run;
**EDIT for Stu's suggestion to use 'proc sort' and then omit 'discreteorder' :
The result then is that the first values on the y axis are only the StationAreas that B01 have responded to.




Sort your data by
StationArea Battalion, then create the heatmap without theyaxis discreteorderoption.If you have Battalions that go above 10, you can ensure it stays in the right order by extracting the number and sorting by it. You can extract the number with
battalion_nbr = input(substr(Battalion, 2, 2), 8.);. For example: