I have some data:
x = 1 0 2 0 3 1 0 1 2 0; y = 16 9 17 12 22 13 8 15 19 11;
I'd like to generate an estimated regression function and plot the line on top of the data scatter plot.
I tried searching for a tutorial or some kind of example, but couldn't find any (that I understood and that worked when i tried plugging them in).
Not sure if this is what you are after?
data have;
input x y;
datalines;
1 16
0 9
2 17
0 12
3 22
1 13
0 8
1 15
2 19
0 11
;
ods select FitPlot;
proc reg data=have;
model y = x;
run;quit;
Hi,
Try proc sgplot.
And the SGPLOT - which gives you more control over the colours and graph attributes:
title 'My demo plot';
proc sgplot data=have;
scatter x=x y=y ;
reg x=x y=y / lineattrs=(color=CXf03b20);
run;
Not sure if this is what you are after?
data have;
input x y;
datalines;
1 16
0 9
2 17
0 12
3 22
1 13
0 8
1 15
2 19
0 11
;
ods select FitPlot;
proc reg data=have;
model y = x;
run;quit;
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.
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.