Programming the statistical procedures from SAS

Contrasts in SAS

Reply
Occasional Contributor
Posts: 9

Contrasts in SAS

[ Edited ]

I am new at working with contrasts. I was interested in resources to learn how to create contrasts. 

 

Also, I need help with one of my analyses - I have 3 factors: a (high and low), b (red and white), c (small, medium, large). I need to create contrasts for the main effect of the three level factor to compare small vs. medium, small vs. large and medium vs. small and also two-way interactions between factors. How would those contrasts look like, I am getting hung up on it. 

 

proc glimmix data=test;
class a b c;
model outcome=a b c a*b a*c b*c / dist=normal;
lsmeans a b c;

lsmeans a*b a*c b*c;

contrast .....

 

Thanks,

M

Super User
Posts: 23,771

Re: Contrasts in SAS

Posted in reply to mmjohnson

mmjohnson wrote:

I am new at working with contrasts. I was interested in resources to learn how to create contrasts. 

 

 

Thanks,

M


Here's a good resource: 

https://support.sas.com/resources/papers/proceedings11/351-2011.pdf

 

 

SAS Employee
Posts: 386

Re: Contrasts in SAS

Posted in reply to mmjohnson

You don't generally need CONTRAST statements for pairwise comparisons of effect levels and it is safer to avoid it when possible. Simply add the DIFF option in your LSMEANS statement. This note discusses the use of statements like LSMEANS, LSMESTIMATE, and SLICE for most comparisons since you don't have to work out the contrast coefficients when using these statements. But it also goes into detail on using CONTRAST and ESTIMATE statements for more general testing and estimation in which these statements might be needed.

 

This statement produces the pairwise comparisons among your C levels:

 

lsmeans c / diff;

 

See the options available in the LSMEANS statement which might be of use, such as the OM= and BYLEVEL options when dealing with unbalanced data.

Ask a Question
Discussion stats
  • 2 replies
  • 199 views
  • 4 likes
  • 3 in conversation