BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
RAGC
Obsidian | Level 7

I am trying to determine the interaction and main effects for my proc genmod model. I have two variables: varA has 4 categories and is categorized as 0-3, varB has 3 categories and is categorized as 0-2. 

 

I have tried using the following code;

 

proc gemnod;

class varA  (ref='3') varB (ref='0');

model Y = varA|varB;

estimate 'varA main effects of group 0 versus group 3' varA 3 0 0 -3 varA*varB 1 1 1 0 0 0 0 0 0 -1 -1 -1/divisor=3 exp;

run;

 

but keep getting non-est. Can anyone help? 

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

As I've said many times here and as is strongly reiterated in this note on the ESTIMATE and CONTRAST statements, the thing is to always avoid those statements when other statements can be used. The LSMEANS, SLICE, and LSMESTIMATE statements can be used for most purposes and that is certainly the case here. There are several notes in the SAS support knowledgebase showing examples that use all of these statements to do the same thing in a model involving interactions. The simplest way to do what you want is with a basic LSMEANS statement:

 

lsmeans varA / diff;

 

That statement will give all pairwise comparisons, so you can just pick out the one(s) you want. Another simple statement that will give the one particular comparison (level 1 - level 4) you show is

 

lsmestimate varA 1 0 0 -1;

 

To see the coefficients that you would use in an equivalent ESTIMATE statement, add the E option in the above statement. Note that you could still get non-estimable comparisons with these statements. If so, you might try using the OM= and BYLEVEL options in the above statements. See the descriptions of these statements and options in the Shared Concept and Topics chapter of the SAS/STAT User's Guide. 

 

The SLICE statement is not needed for this comparison, but you would use it if you want to, say, compare levels of varA within each level of varB. Again, see the many examples in the knowledgebase.

 

View solution in original post

7 REPLIES 7
PaigeMiller
Diamond | Level 26

One cause for "non-est" is that at least one of the cells in your design is empty. Check for that.

 

Also, it is never going to work if you spell the name of the PROC wrong.

--
Paige Miller
RAGC
Obsidian | Level 7
That was a typo re: genmod. And none of my cells are empty. Thank you for the suggestion.
PaigeMiller
Diamond | Level 26

Okay, please convince me that there are no empty cells by running PROC FREQ, and show us the results.

 

proc freq data=yourdatasetname;
     tables varA*varB;
run;

Another possible cause for non-est is that you don't have the right coefficients typed in for the ESTIMATE statement. You might want to consider the SLICE command instead of the ESTIMATE command, which avoids this issue.

 

In the future, please do not type SAS code into your reply; do yourself a favor, and do all of us a favor, copy and paste the actual code you are using so we don't get distracted by spelling errors or missing semi-colons or similar.

--
Paige Miller
RAGC
Obsidian | Level 7

RAGC_0-1625775433414.png

I am not familiar with the slice command. I will look into it. Thank you. 

sbxkoenk
SAS Super FREQ

Hello,

 

I haven't checked your estimate statement (yet).

And I don't know how well you know about correctly specifying estimate and contrast statements (available in many procedures).

As I have once gathered a lot of blogs on this for a former statistics professor of mine, I thought I would publish the list again here. Maybe you (and others) can profit from it.

Let us know if you can sort it out.

 

The magical ESTIMATE (and CONTRAST) statements

By Chris Daman on SAS Learning Post April 23, 2012

https://blogs.sas.com/content/sastraining/2012/04/23/the-magical-estimate-and-contrast-statements/

 

"Easy button" for ESTIMATE statements

By Chris Daman on SAS Learning Post April 25, 2012

https://blogs.sas.com/content/sastraining/2012/04/25/easy-button-for-estimate-statements/

 

ESTIMATE Statements - the final installment

By Chris Daman on SAS Learning Post May 2, 2012

https://blogs.sas.com/content/sastraining/2012/05/02/estimate-statements-the-final-installment/

 

How to write CONTRAST and ESTIMATE statements in SAS regression procedures?

By Rick Wicklin on The DO Loop June 6, 2016

https://blogs.sas.com/content/iml/2016/06/06/write-contrast-estimate-statements-sas-regression-proce...

 

Usage Note 24447: Examples of writing CONTRAST and ESTIMATE statements

https://support.sas.com/kb/24/447.html

 

Usage Note 67024: Using the ESTIMATE or CONTRAST statement or Margins macro to assess continuous variable effects in interactions and splines

67024 - Using the ESTIMATE or CONTRAST statement or Margins macro to assess continuous variable effe...

 

Cheers,
Koen

StatDave
SAS Super FREQ

As I've said many times here and as is strongly reiterated in this note on the ESTIMATE and CONTRAST statements, the thing is to always avoid those statements when other statements can be used. The LSMEANS, SLICE, and LSMESTIMATE statements can be used for most purposes and that is certainly the case here. There are several notes in the SAS support knowledgebase showing examples that use all of these statements to do the same thing in a model involving interactions. The simplest way to do what you want is with a basic LSMEANS statement:

 

lsmeans varA / diff;

 

That statement will give all pairwise comparisons, so you can just pick out the one(s) you want. Another simple statement that will give the one particular comparison (level 1 - level 4) you show is

 

lsmestimate varA 1 0 0 -1;

 

To see the coefficients that you would use in an equivalent ESTIMATE statement, add the E option in the above statement. Note that you could still get non-estimable comparisons with these statements. If so, you might try using the OM= and BYLEVEL options in the above statements. See the descriptions of these statements and options in the Shared Concept and Topics chapter of the SAS/STAT User's Guide. 

 

The SLICE statement is not needed for this comparison, but you would use it if you want to, say, compare levels of varA within each level of varB. Again, see the many examples in the knowledgebase.

 

PaigeMiller
Diamond | Level 26

@StatDave said:

As I've said many times here and as is strongly reiterated in this note on the ESTIMATE and CONTRAST statements, the thing is to always avoid those statements when other statements can be used. The LSMEANS, SLICE, and LSMESTIMATE statements can be used for most purposes and that is certainly the case here.

Agreeing completely. And I have bookmarked the link. Thanks!

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 1333 views
  • 2 likes
  • 4 in conversation