SGPLOT will always use all the data provided to the regression statement to compute the fit line. There is no way to draw only part of the fit line. One possibility would be to compute a new Y2 column that has missing values for x>50. Then, provide Y2 to the reg statement, while you still provide the original Y column to the scatter plot. However, this may not be correct since the new regression line will not be the same as the one with full data. Now, SGPLOT computes a new data set with the values needed to draw the regression line as a series plot. So, you could use ODS Output to get this computed data set, remove the points of the fit line for x > 50, and then use a SERIES statement to draw the truncated fit line. Note, this idea works with degree=2, as many points are computed. With default degree=1, only the two end points are computed, so that would get tricky. Here is a program using class data to illustrate the idea: ods output sgplot=Reg; proc sgplot data=sashelp.class; reg x=height y=weight / group=sex degree=2; run; proc print data=reg;run; data reg2; set reg; y2=REGRESSION_HEIGHT_WEIGHT_GROU__Y; if REGRESSION_HEIGHT_WEIGHT_GROU__X >65 then y2=.; run; proc print data=reg2;run; proc sgplot data=reg2; scatter x=height y=weight / group=sex; series x=REGRESSION_HEIGHT_WEIGHT_GROU__X y=y2 / group=REGRESSION_HEIGHT_WEIGHT_GROU_GP; run;
... View more