ods graphics on / attrpriority=none; data x; do i = 1 to 100; g = 1; x = 10 * uniform(17); y = x + 2 * sin(x) + normal(17); output; g = 2; x = 10 * uniform(17); y = 5 - x - 2 * cos(x) + normal(17); output; end; run; proc sgplot data=x noautolegend; styleattrs datalinepatterns=(solid) datasymbols=(circlefilled squarefilled); pbspline y=y x=x / group=g; run; data b(keep= x y); m = 10; do x = 1 to 10; m + normal(368) + ifn(uniform(368) > .3, 3, -0.5); do i = 1 to 20; y = m + normal(7); output; end; end; run; proc means data=b noprint; var y; class x; output out=means(where=(_stat_='MEAN' and n(x))); run; data box; merge b means(rename=(y=ymeans x=xmeans) keep=x y); run; proc sgplot data=box noautolegend; vbox y / category=x; series y=ymeans x=xmeans; xaxis type=linear display=all; run; proc sgplot data=box noautolegend; scatter y=y x=x; series y=ymeans x=xmeans; xaxis type=linear display=all; run; proc transreg data=x noprint; model identity(y) = mspline(x / nknots=9) | class(g / zero=none) / maxiter=100; output out=msp(keep=y x py g) p; run; proc sort data=msp; by g x; run; proc sgplot data=msp noautolegend; styleattrs datalinepatterns=(solid) datasymbols=(circlefilled squarefilled); scatter y=y x=x / group=g; series y=py x=x / group=g lineattrs=(thickness=2); run; proc transreg data=b noprint; model identity(y) = monotone(x) / maxiter=100; output out=msp2(keep=y x py) p; run; proc sort data=msp2(drop=y) out=msp2(rename=(py=ymeans x=xmeans)); by x; run; data msp2; set msp2; by xmeans; if first.xmeans; run; data box2; merge b msp2; run; proc sgplot data=box2 noautolegend; vbox y / category=x; series y=ymeans x=xmeans; xaxis type=linear display=all; run; proc sgplot data=box2 noautolegend; scatter y=y x=x; series y=ymeans x=xmeans; xaxis type=linear display=all; run;