data cholesterol; keep deathcause cholesterol; set sashelp.heart; if deathcause ne ''; run; * first I'm just generating an index for your earlier dataset so that I don't have to create a dataset sorted by deathcause; proc datasets library=work; modify cholesterol; index create deathcause; run; quit; data _null_; set cholesterol end=last; retain min max; max=max(cholesterol, max); min=min(cholesterol, min); if last then do; call symput ("Max", max); call symput ("Min", min); end; run; * kde stands for kernel desnity estimation and the procedure does just that; proc kde data = cholesterol; by deathcause; univar cholesterol(gridl=&Min gridu=&max) / NGRID=401 unistats percentiles plots=none /*(plots=(density HISTDENSITY)*/ out = chol_dens (rename=(value=cholesterol) drop=var); run; proc print data = chol_dens; run; %let gpath='C:\'; %let dpi=200; proc template; define statgraph DensityStrip; begingraph; rangeattrmap name='map'; range min-max / rangecolormodel=(white cx445694); endrangeattrmap; rangeattrvar var=density attrvar=density attrmap='map'; entrytitle 'Cholesterol Density Strip'; layout overlay / xaxisopts=(label='Cholesterol' linearopts=(tickvaluesequence= (start=0 end=500 increment=100))) yaxisopts=(display=(tickvalues)); heatmapparm x=cholesterol y=deathcause colorresponse=density / xbinaxis=false ygap=5px colormodel=TWOCOLORRAMP name="heatmapparm"; continuouslegend "heatmapparm" / location=outside; endlayout; endgraph; end; run; ods html close; ods listing gpath=&gpath image_dpi=&dpi style=htmlblue; ods graphics / reset width=5in height=2in imagename='DensityStrip'; proc sgrender data=chol_dens template=DensityStrip; run;