Data visualization with SAS programming

Proc SGPLOT - Extend trend line full width of graph

Accepted Solution Solved
Reply
Contributor
Posts: 28
Accepted Solution

Proc SGPLOT - Extend trend line full width of graph


I am using the reg statement in proc sgplot to create a trend line -- I'd like the trend line to begin at the y axis, not begin with the first data point. I couldn't find a way to do this with lineattrs in the documentation. Any tips are greatly appreciated. Thanks

proc sgplot data=sample;

     scatter x=x y= y;

     reg x=x y=y /nomarks lineattrs=(color=black);

run;


Accepted Solutions
Solution
‎01-28-2014 01:45 PM
SAS Employee
Posts: 967

Re: Proc SGPLOT - Extend trend line full width of graph

The behavior you're describing is the default for Proc Gplot - here's an example:

data foo;
input x y;
datalines;
1 3
2 4
3 5
4 7
5 6
;
run;

symbol1 value=none interpol=rl color=blue;
symbol2 value=dot interpol=none color=red;

axis1 order=(0 to 6 by 2);
axis2 order=(0 to 10 by 2);

proc gplot data=foo;
plot y*x=1 y*x=2 / overlay haxis=axis1 vaxis=axis2;
run;

gplot.png

View solution in original post


All Replies
SAS Super FREQ
Posts: 1,080

Re: Proc SGPLOT - Extend trend line full width of graph


You cannot "extend" the fit line, but you can remove the extra white space.  Try setting OFFSETMIN=0 and THRESHOLDMIN=0 (SAS 9.3) on the x axis.  Same on the other end.

Solution
‎01-28-2014 01:45 PM
SAS Employee
Posts: 967

Re: Proc SGPLOT - Extend trend line full width of graph

The behavior you're describing is the default for Proc Gplot - here's an example:

data foo;
input x y;
datalines;
1 3
2 4
3 5
4 7
5 6
;
run;

symbol1 value=none interpol=rl color=blue;
symbol2 value=dot interpol=none color=red;

axis1 order=(0 to 6 by 2);
axis2 order=(0 to 10 by 2);

proc gplot data=foo;
plot y*x=1 y*x=2 / overlay haxis=axis1 vaxis=axis2;
run;

gplot.png

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 2432 views
  • 3 likes
  • 3 in conversation