BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
OPHD1
Fluorite | Level 6


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;

1 ACCEPTED SOLUTION

Accepted Solutions
GraphGuy
Meteorite | Level 14

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

2 REPLIES 2
Jay54
Meteorite | Level 14


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.

GraphGuy
Meteorite | Level 14

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

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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