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-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 3 replies
  • 514 views
  • 4 likes
  • 4 in conversation