Hello
I would like to test the variable "beta", "gamma", and "alpha" (these are continuous variables) in two different level of "pet_type". Pet_type is a class variable with two values: "dog" or "cat". Ultimately, I would like to have a graph something like this
my code is
proc glm data = have ;
class pet_type ;
model logsale = beta gamma alpha pet_type pet_type*beta pet_type*gamma pet_type*alpha/ss3;
lsmeans pet_type*gamma/ slice = pet_type;
lsmeans pet_type*beta/ slice = pet_type;
lsmeans pet_type*alpha/ slice = pet_type;
run;
but I've got an error message that "only CLASS variables allowed in this effect." Please help!
That was supposed to be , because 'dog' is reference level of class variable.
You could see X*DRUG G is also zero in the following picture(the parameter of reference level is supposed to be zero) .
Here " some value for cat " represent the difference of slope between CAT and DOG,check yellow part in picture.
X(or alpha) represent then solpe of DOG(reference level), check blue part in picture.
"get the results for both cat and dog? "
What do you mean by "results" ?
1) If you refer to mean of Y, "Intercept" is the mean of Y for DOG when alpha=0 .
"CAT" is the difference in the mean of Y between CAT and DOG when alpha=0, then the mean of Y for CAT=CAT+Intercept.
2)If you refer to slope of Y, "Alpha" is the slope for DOG.
alpha*cat is the difference in the slopes of the CAT and DOG, then then slope for CAT=alpha*cat +alpha .
Above all these you can find at the link I posted, just read it carefully and understand it .
Thank you for letting me know! Pet_type is a category variable but alpha, beta, and gamma are not.. so what do you suggest?
thank you! I reviewed the document and used the last one.
Pet_type is a class variable (either "cat" or "dog")
proc glm data=pet; ods select ParameterEstimates; class pet_type; model Y = pet_type alpha pet_type*alpha / solution; run;
The results show some value for cat but only zero and "." for dog. How can I get the results for both cat and dog?
That was supposed to be , because 'dog' is reference level of class variable.
You could see X*DRUG G is also zero in the following picture(the parameter of reference level is supposed to be zero) .
Here " some value for cat " represent the difference of slope between CAT and DOG,check yellow part in picture.
X(or alpha) represent then solpe of DOG(reference level), check blue part in picture.
"get the results for both cat and dog? "
What do you mean by "results" ?
1) If you refer to mean of Y, "Intercept" is the mean of Y for DOG when alpha=0 .
"CAT" is the difference in the mean of Y between CAT and DOG when alpha=0, then the mean of Y for CAT=CAT+Intercept.
2)If you refer to slope of Y, "Alpha" is the slope for DOG.
alpha*cat is the difference in the slopes of the CAT and DOG, then then slope for CAT=alpha*cat +alpha .
Above all these you can find at the link I posted, just read it carefully and understand it .
thank you so much. I ended up manually calculated intercepts and slopes and draw lines in excel not the most sophisticated way but still worked
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.