%let gpath='C:\';
%let dpi=200;
ods html close;
ods listing gpath=&gpath image_dpi=&dpi;
proc means data=sashelp.cars(where=(type ne 'Hybrid')) noprint completetypes;
class origin type;
var mpg_city horsepower;
output out=cars_means
mean(mpg_city horsepower) = mean_mpg mean_hp
N=N;
run;
proc sort data=sashelp.cars(where=(type ne 'Hybrid')) out=cars_sort;
by origin type;
run;
proc sort data=cars_means(where=(_type_ = 3));
by origin type;
run;
data cars;
keep origin type mpg_city horsepower mean_mpg mean_hp n size;
merge cars_sort cars_means(where=(_type_ = 3));
by origin type;
size=100;
if first.type then do; mean_mpg=25; mean_hp=300; end;
else do; mean_mpg=.; mean_hp=.; end;
run;
/*--Lattice with color background by count--*/
proc template;
define statgraph GradientPanelWall;
begingraph;
entrytitle 'Vehicle Statistics';
layout gridded / columns=2;
layout datalattice columnvar=origin rowvar=type / columns=3 headerlabeldisplay=value
rowaxisopts=(offsetmin=0.1 offsetmax=0.1)
columnaxisopts=(offsetmin=0.1 offsetmax=0.1);
layout prototype;
bubbleplot x=mean_hp y=mean_mpg size=size / colorresponse=n name='a' colormodel=twocolorramp
bubbleradiusmin=300 bubbleradiusmax=400 datatransparency=0.5;
scatterplot x=horsepower y=mpg_city / primary=true;
endlayout;
endlayout;
continuouslegend 'a' / title='Observation Counts' halign=right orient=vertical;
endlayout;
endgraph;
end;
run;
/*--Lattice with color background by count--*/
ods graphics / reset width=5in height=5in imagename='GradientPanelWall';
proc sgrender data=cars template=GradientPanelWall;
run;
/*--Lattice with color background by count with legend pad--*/
proc template;
define statgraph GradientPanelWallPad;
begingraph;
entrytitle 'Vehicle Statistics';
layout gridded / columns=2;
layout datalattice columnvar=origin rowvar=type / columns=3 headerlabeldisplay=value
rowaxisopts=(offsetmin=0.1 offsetmax=0.1)
columnaxisopts=(offsetmin=0.1 offsetmax=0.1);
layout prototype;
bubbleplot x=mean_hp y=mean_mpg size=size / colorresponse=n name='a' colormodel=twocolorramp
bubbleradiusmin=300 bubbleradiusmax=400 datatransparency=0.5;
scatterplot x=horsepower y=mpg_city / primary=true;
endlayout;
endlayout;
continuouslegend 'a' / title='Observation Counts' halign=right orient=vertical
pad=(bottom=50 top=18 left=10);
endlayout;
endgraph;
end;
run;
/*--Lattice with color background by count with legend pad--*/
ods graphics / reset width=5in height=5in imagename='GradientPanelWallPad';
proc sgrender data=cars template=GradientPanelWallPad;
run;
/*--Add non-match-merged count data for insets--*/
/*--Note: Order of by vars is reversed--*/
proc sort data=cars_means(where=(_type_ = 3));
by type origin;
run;
data cars2;
label count='N=';
merge cars cars_means(keep=n rename=(n=count));
run;
/*--Lattice with color background by count with legend pad and insets--*/
proc template;
define statgraph GradientPanelWallInset;
begingraph;
entrytitle 'Vehicle Statistics';
layout gridded / columns=2;
layout datalattice columnvar=origin rowvar=type / columns=3 headerlabeldisplay=value
rowaxisopts=(offsetmin=0.1 offsetmax=0.1)
columnaxisopts=(offsetmin=0.1 offsetmax=0.1)
inset=(count) insetopts=(autoalign=none halign=right valign=top);
layout prototype;
bubbleplot x=mean_hp y=mean_mpg size=size / colorresponse=n name='a'
bubbleradiusmin=300 bubbleradiusmax=400 datatransparency=0.5;
scatterplot x=horsepower y=mpg_city / primary=true;
endlayout;
endlayout;
continuouslegend 'a' / title='Observation Counts' halign=right orient=vertical
pad=(bottom=50 top=18 left=10);
endlayout;
endgraph;
end;
run;
/*--Lattice with color background by count with legend pad and insets--*/
ods graphics / reset width=5in height=5in imagename='GradientPanelWallInset';
proc sgrender data=cars2 template=GradientPanelWallInset;
run;