BookmarkSubscribeRSS Feed
6 REPLIES 6
kukie
Fluorite | Level 6

Hi, I am trying to find the estimates related to the effects of  gender on the relationship between two variables. 

I used an estimate statement in the code as follows....

 
proc surveyreg data=nhanes4 order=formatted;
cluster SDMVPSU;
strata SDMVSTRA;
weight WTSH2YR;
class vaper riagendr age race income cigs bmi;
model loglead= vaper|riagendr ridageyr bmxbmI race income cigs/
solution clparm;
format vaper vaperf. riagendr genderf. race racef. income
incomef. cigs cigsf. ;
estimate 'comparing males and females' riagendr -1 1/exp;
title "Model with Gender Interaction Term";
run;
 
somehow, I am not able to get the estimates for males and the estimates for females. Rather, it gives me a single estimate with male as the reference. Is there another way I can code this to give me two separate estimates, one each for male and females?
 
thanks
SAS_Rob
SAS Employee

Since gender is involved in an interaction you really can't look at a single parameter estimate to get the estimates for each of the two groups.  In this case it is probably easiest to use the LSMEANS statement.

lsmeans riagendr;

SteveDenham
Jade | Level 19

I think what you are calling estimates are estimates of the parameters, which under the non-full rank parameterization used, sets the last category to zero.  Using the LSMEANS statement combines the necessary elements to calculate the expected population mean for each level of a categorical variable.

 

This is a case where using the LSMEANS and LSMESTIMATE statement is an advantage;  Try adding this to your code:

 

lsmeans vaper|riagender/e;
lsmestimate riagender "Males vs Females, averaged over vaper status' -1 1/exp;
lsmestimate vaper*riagender 'Males vs Females, vaper status=no'  -1 1 0 0,
                                                'Males vs Females, vaper status=yes' 0 0 -1 1/exp;

You may need to rearrange the coefficients in the second LSMESTIMATE statement to reflect the parameterization given in the LSMEANS statement by the /e option.

 

SteveDenham

 

 

kukie
Fluorite | Level 6

Hi Steve,

 

Thanks for this. The challenge I have now is that I have three levels of vapers - never vapers, former vapers and current vapers and I am struggling with the parameterization. I am unsure how to account for the three levels.

 

Thank you

SteveDenham
Jade | Level 19

That should not present a problem - once again it is why LSMESTIMATE statements are so useful.

 

lsmeans vaper|riagender/e;
lsmestimate riagender "Males vs Females, averaged over vaper status' -1 1/exp;
lsmestimate vaper*riagender 'Males vs Females, vaper status=never'  -1 1  0 0  0 0,
                            'Males vs Females, vaper status=former' 0 0  -1 1  0 0,
                            'Males vs Females, vaper status=current' 0 0  0 0  -1 1/exp;

This now gets trickier.  I just stuck these in, and the correct version depends on the ordering of vaper levels.  Since there is nothing in the CLASS statement and I assume that the levels are in fact  'Current', 'Former', and 'Never', the lsmeans will sort in alphabetical order.  That means the code should look like:

 

lsmeans vaper|riagender/e;
lsmestimate riagender "Males vs Females, averaged over vaper status' -1 1/exp;
lsmestimate vaper*riagender 'Males vs Females, vaper status=current'  -1 1  0 0  0 0,
                            'Males vs Females, vaper status=former' 0 0  -1 1  0 0,
                            'Males vs Females, vaper status=never' 0 0  0 0  -1 1/exp;

If there is another coding for the vaper levels, it can be handled once you know the order that things appear in the LSMEANS statement.

 

SteveDenham.

 

 

kukie
Fluorite | Level 6

Thank you Steve,

 

 

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
  • 6 replies
  • 608 views
  • 3 likes
  • 3 in conversation