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

Hello,

This is my first time writing here. I have mortality data from a cohort study. I've been trying to calculate incidence rates for mortality with no success. I used proc genmod with lsmeans to estimate the IR using Poisson, but the results are very very different from those obtained by my colleague using STATA.This is the code I've been using:

 

proc genmod data=muj;
class muerto diabetes(ref=first) educacion(ref=first) sexo(ref=last);
model muerto=edad educacion  diabetes/dist=poisson
                        link=log
                        offset=logpyears;
lsmeans diabetes/ilink exp cl diff OM;
run;

 The stata code used for this is the following:

 

poisson muerto i.diabetes i.cat_edad i.educacion, exposure(pyears) irr
margins diabetes, predict(ir)

 

Is there some procedure or code that gives me adjusted incidence rates?

Thanks to all in advance

1 ACCEPTED SOLUTION

Accepted Solutions
StatDave
SAS Super FREQ

You would need to fit exactly the same model in both SAS and Stata since any difference in the fitted model can cause a difference, large or small, in estimated values. A predictive margin for a level of your predictor is the average predicted value when all observations in your data have the predictor set to that level. So, you could easily compute the point estimate of the margin by creating a copy of your data set with your predictor set to one level and then compute all the predicted values and average them.

 

View solution in original post

8 REPLIES 8
Miracle
Barite | Level 11
Hi, it maybe helpful to post the Stata code as well?
Ximena_O
Fluorite | Level 6
Thanks for the tip, just included the stata code in the question. 🙂
Ximena_O
Fluorite | Level 6

Thanks 😄

StatDave
SAS Super FREQ

The SAS code looks correct and follows what is discussed in this note. But your Stata code looks like the model only has one predictor while your SAS code has three, so that will clearly cause a difference. Additionally, note that the predictive margin computed in Stata is not the same as an LS-mean.

Ximena_O
Fluorite | Level 6
What would be the equivalent in SAS fro the margin computed in STATA?
(we've been varying the covariates, so it is possible that the codes are a little different, but the results we get are different anyway)
StatDave
SAS Super FREQ

You would need to fit exactly the same model in both SAS and Stata since any difference in the fitted model can cause a difference, large or small, in estimated values. A predictive margin for a level of your predictor is the average predicted value when all observations in your data have the predictor set to that level. So, you could easily compute the point estimate of the margin by creating a copy of your data set with your predictor set to one level and then compute all the predicted values and average them.

 

Ximena_O
Fluorite | Level 6
Just updated the code for STATA...thanks

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
  • 8 replies
  • 7509 views
  • 1 like
  • 4 in conversation