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;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.