If you have SAS 9.2, you can run the code below to get what you want. YOu only need to submit the template once. After that, you can run PROC SGRENDER with different data sets and X/Y variables. Let me know if you have any questions.
Thanks!
Dan
proc template;
define statgraph histplot;
dynamic XVAR YVAR;
begingraph;
layout lattice / columndatarange=union columngutter=10 columnweights=(0.75 0.25 ) columns=2
rowdatarange=union rowgutter=10 rowweights=(0.25 0.75 ) rows=2;
layout overlay;
histogram XVAR / binaxis=false name='histogram';
endlayout;
layout overlay;
entry halign=center ' ' / valign=center;
endlayout;
layout overlay;
scatterplot x=XVAR y=YVAR / name='scatter';
endlayout;
layout overlay;
histogram YVAR / binaxis=false name='histogram_h' orient=horizontal;
endlayout;
rowaxes;
rowaxis;
rowaxis;
endrowaxes;
columnaxes;
columnaxis;
columnaxis;
endcolumnaxes;
endlayout;
endgraph;
end;
run;
proc sgrender data=SASHELP.CLASS template=histplot;
dynamic XVAR="weight" YVAR="height";
run;