%let gpath='C:\'; %let dpi=200; ods html close; ods listing gpath=&gpath image_dpi=&dpi;; /*--Numeric x Numeric Heat Map--*/ proc template; define statgraph HeatMapNumNum; dynamic _x _y _n; begingraph; entrytitle 'Distribution of Age by Systolic Blood Pressue'; layout overlay; heatmapparm x=_x y=_y colorresponse=_n / colormodel=(white yellow red) display=(fill outline) outlineattrs=(color=cxf7f7f7) xbinaxis=false ybinaxis=false name='h'; continuouslegend 'h'; endlayout; endgraph; end; run; /*--Bivariate binning using KDE procedure--*/ ods graphics on; ods trace off; ods output bivariatehistogram=KDEData; proc kde data=sashelp.heart; bivar systolic ageatstart / plots=all ng=100; run; ods graphics off; /* ods html;*/ /* proc print data=KDEData; run;*/ /* ods html close;*/ /*--Heat Map from KDE data--*/ ods graphics / reset width=5in height=3in imagename='HeatMapNumNum'; proc sgrender data=KDEData template=HeatMapNumNum; dynamic _x='binx' _y='biny' _n='bincount'; run; /*--Bivariate binning using SurveyReg procedure--*/ ods graphics on; ods trace off; ods output fitplot=SurveyRegData; proc surveyreg data=sashelp.heart plot=fit(shape=rec nbins=30); model AgeAtStart = Systolic; run; /*--Heat Map from SurveyReg data--*/ ods graphics / reset width=3.5in height=3in imagename='HeatMapNumNum2'; proc sgrender data=SurveyRegData template=HeatMapNumNum; dynamic _x='xvar' _y='yvar' _n='wvar'; run; /*--Numeric by Discrete Heatmap--*/ proc template; define statgraph HeatMapCatNum; dynamic _title _x _y _n; begingraph; entrytitle _title; layout overlay / yaxisopts=(display=(ticks tickvalues)); heatmapparm x=_x y=_y colorresponse=_n / colormodel=(white green yellow red) display=(fill outline) outlineattrs=(color=cxf7f7f7) name='h' ; continuouslegend 'h'; endlayout; endgraph; end; run; /*--Get bin counts for categorical by numeric data--*/ ods output sgplot=groupedBins; ods graphics / reset width=5in height=3in imagename='GroupedHistogramSystolic'; proc sgplot data=sashelp.heart(where=(deathcause ne '')); histogram systolic / group=deathcause nbins=32 scale=count; run; /*--Clean up data set--*/ data bins; set groupedBins(rename=(BIN_SYSTOLIC_GROUP_DEATHCAUSE__X=X BIN_SYSTOLIC_GROUP_DEATHCAUSE_GP=Y BIN_SYSTOLIC_GROUP_DEATHCAUSE__Y=N)); drop systolic deathcause; if x ne .; run; /*--Heat Map from SGPLOT data--*/ ods graphics / reset width=5in height=1.3in imagename='HeatMapCatNum'; proc sgrender data=bins template=HeatMapCatNum; dynamic _title='Systolic by Death Cause' _x='x' _y='y' _n='n'; run;