data d; input y x; diff=y-225.5625; * sample mean of y's from proc means below; datalines; 199.0 16.0 205.0 16.0 196.0 16.0 200.0 16.0 218.0 24.0 220.0 24.0 215.0 24.0 223.0 24.0 237.0 32.0 234.0 32.0 235.0 32.0 230.0 32.0 250.0 40.0 248.0 40.0 253.0 40.0 246.0 40.0 ; proc means data d; run; *used to get Ybar; proc reg; *get residuals; model y=x; output out=res r=r; run; * first way doesn't get plots on same scale but is easier; proc sgscatter; compare y=(diff r) x=x; run; * 2nd way uses same scale but takes more work; data plotdata; set res; y=diff; plt=1; output; y=r; plt=2; output; run; proc format; value plt 1="Y_i-Ybar" 2="Y_i-Yhat_i"; run; proc sgpanel data = plotdata; panelby plt / rows=2 columns=1 novarname; scatter x=x y=y; format plt plt.; run;