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

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).

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

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;

View solution in original post

3 REPLIES 3
Reeza
Super User

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;
PeterClemmensen
Tourmaline | Level 20

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;

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 864 views
  • 4 likes
  • 4 in conversation