BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Lena_PA
Fluorite | Level 6

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 

Lena_PA_0-1699341128993.png

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! 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

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

Ksharp_0-1727923861652.png

 

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 .

View solution in original post

6 REPLIES 6
Ksharp
Super User
Since LSMEANS compare the mean of Y in two or more groups within CLASS variable, like ANOVA . You should use CATEGORY variable in it.
lsmeans pet_type*gamma/ slice = pet_type;
-->
lsmeans pet_type/ diff ;
Lena_PA
Fluorite | Level 6

Thank you for letting me know! Pet_type is a category variable but alpha, beta, and gamma are not.. so what do you suggest?

Ksharp
Super User
If You want to check the difference of ALPHA within a category variable,you should check this :

https://support.sas.com/kb/38/384.html
Lena_PA
Fluorite | Level 6

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? 

Ksharp
Super User

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

Ksharp_0-1727923861652.png

 

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 .

Lena_PA
Fluorite | Level 6

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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 6 replies
  • 1198 views
  • 2 likes
  • 2 in conversation