turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- SAS/GRAPH and ODS Graphics
- /
- Is it possible to show a regression line for speci...

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

01-28-2014 01:30 PM

I have 10 data points representative of years (2003-2012). I would like to show the regression line for the first 8 points (2003-2010) and have the last two points stand alone. Is it possible to accomplish this with GPlot?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to KageKitsune28

01-28-2014 01:35 PM

Easily done with SGPLOT. Move the last two points to new columns (x2, y2) and make them missing in the original columns (x, y). Now plot a regressioin plot using original columns (x, y). Overlay a scatter plot with new columns (x2, y2).

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

01-28-2014 01:54 PM

Great! I am going to try that. Thank you!

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Sanjay_SAS

01-28-2014 03:53 PM

Well this was working great until I added the regression line. The regression line is stretching across all 10 points instead of stopping at 8.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to KageKitsune28

01-28-2014 03:56 PM

Are you using gplot, or sgplot?

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobertAllison_SAS

01-28-2014 04:00 PM

gplot

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to KageKitsune28

01-28-2014 04:05 PM

The built-in gplot interpol=rl regression line is going to always go all the way to the axis (I think).

If you just want the regression line to go to a certain point (and not all the way to the axis), then I think you'll need to calculate the points along the regression line (such as using Proc Reg), and then plot those points using interpol=join.

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to RobertAllison_SAS

01-28-2014 04:09 PM

Or, just use SGPLOT.

data fit;

do x2=1 to 8;

y2=10+2*rannor(2); output;

end;

x2=.; y2=.;

do x=9 to 10;

y=10+2*rannor(2); output;

end;

run;

proc sgplot data=fit;

reg x=x2 y=y2 / name='r';

scatter x=x y=y;

keylegend 'r';

run;

- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to KageKitsune28

01-28-2014 01:54 PM

Similar to what Sanjay was saying about sgplot, you could also do this with gplot.

See the 'Forecast Line' example, near the middle of this Line Plot chapter for an example: