BookmarkSubscribeRSS Feed
JUMMY
Obsidian | Level 7

How do I fit a model that allows for different slopes and intercepts for the two brands (A and B) and then find a final model (a regression line) for the data below?

 

data model;
	input make $ speed cost @@;
	datalines;
	A 10 9.8 A 20 12.5 A 20 14.2 A 30 14.9 
	A 40 19.0 A 40 16.5 A 50 20.9 A 60 22.4
	A 60 24.1 A 70 25.8 B 10 15.0 B 20 14.5
	B 20 16.1 B 30 16.5 B 40 16.4 B 40 19.1
	B 50 20.9 B 60 22.3 B 60 19.8 B 70 21.4
;
run;

proc print data=model;
run;
1 REPLY 1
PaigeMiller
Diamond | Level 26

Different slopes and intercepts for MAKE — you don't say which variable is the Y variable, so I have assumed it is COST, and that SPEED and MAKE are the X variables.

 

proc glm data=model;
    class make;
    model cost = make | speed;
run;
quit;

The vertical bar in the MODEL statement gives you all mean effects involving MAKE and SPEED plus the interaction MAKE*SPEED. The coefficients for MAKE are the deviation of the separate intercepts from the overall intercept, and the interaction MAKE*SPEED are the adjustments to the overall slope so that you now have different slopes for the two different MAKE levels.

 

 

--
Paige Miller

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 1 reply
  • 409 views
  • 0 likes
  • 2 in conversation