The SAS code for the data and plot is below. The regression line will be determined by the 10 data point I have, but I want to control the start and the end of the regression line. For example, I want to keep my current plot, the only change is that I want the regression line begin at day=3 and end at day=8. Now the regression line begin at day=1 and end at day=10. How can I do it?
data my_data;
input day sales;
datalines;
1 7
2 12
3 15
4 14
5 13
6 11
7 10
8 16
9 18
10 24
;
run;
proc sgplot data=my_data;
reg x=day y=sales;
xaxis min=0 max = 12 values=(0 to 12 by 1);
yaxis min=0 max = 25 values=(0 to 25 by 1);
run;
You will have to capture the computed regression line coefficients from
Proc REGoutput and add the endpoints of your desired line segment as rows to the data to be plotted with aSERIESstatement.Since you are going to essentially hide the
SGPLOT REGline you can plot the data points with justSCATTERExample:
The
REGstatement is used for instructive purposes and to show the computed line segment fromProc REGdoes align with the line computed forREGstatement. TheSERIESline was thickened for instructive purposes.