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