One more change...
You wanted one legend for all contours. Now that you are using the rangeattrmap, you can assign the legend to just one plot. See the revised code below:
proc template;
define statgraph contourplotparm;
begingraph;
rangeattrmap name="zcolor";
range min-<5 / rangecolormodel=(threecolorramp:startcolor threecolorramp:neutralcolor);
range 5-5 / rangecolor=orange;
range 5<-max / rangecolormodel=( threecolorramp:neutralcolor threecolorramp:endcolor);
endrangeattrmap;
rangeattrvar attrvar=zdensity var=density attrmap="zcolor";
rangeattrvar attrvar=zdensity1 var=density1 attrmap="zcolor";
rangeattrvar attrvar=zdensity2 var=density2 attrmap="zcolor";
rangeattrvar attrvar=zdensity3 var=density3 attrmap="zcolor";
LAYOUT LATTICE / COLUMNS=2 ROWS=2 ;
layout overlay;
contourplotparm x=height y=weight z=zdensity /
contourtype=fill nhint=12
name="Contour1" colormodel=threecolorramp;
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity1 /
contourtype=fill nhint=12
name="Contour2" colormodel=threecolorramp;
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity2 /
contourtype=fill nhint=12
name="Contour3" colormodel=threecolorramp;
endlayout;
layout overlay;
contourplotparm x=height y=weight z=zdensity3 /
contourtype=fill nhint=12
name="Contour4" colormodel=threecolorramp;
endlayout;
sidebar / align=bottom;
continuouslegend "Contour4"/ title="K";
endsidebar;
endlayout;
endgraph;
end;
run;
ods listing style=toto ;
proc sgrender data=gridded template=contourplotparm;
run;
... View more