Hi all,
I have a fairly straightforward question about subtracting differences in LS Means. I'm pretty sure there is a built in function in SAS to do this, but don't know what it is. Basic need is the following and I'll explain using a table.
What I want to do is calculate differences in LS Means between two comparisons, or essentially a differences in differences. For example, say I want to look at differences in deaths between people with and w/out insurance. Running LS Means to obtain (a - b) and (c - d) is pretty straight forward using the "lsmeans insurance*death / diff cl function". But what I want to get is the aggregate disparity, which i need to do via subtraction + get the associated confidence interval and p value. I'm pretty sure I can just do this by hand using Z test, but it would be way easier if SAS had built in function to obtain what essentially is a differences in differences problem. I've tried using the 'slice by' function, but I'm getting what i normally would get by using the contrast/estimate coding. Thank you for your help.
Disparity Event Table
Alive Dead Disparity
No Insurance a b a-b
Insurance c d c-d
Aggregate Disparity (a-b)–(c-d) * this is what I need
What SAS PROC are you using?
Some SAS PROCs have the LSMESTIMATE statement, this is what you need.
Thanks Paige - I think I figured it out. It looks like SAS generates what I think of as the differences in differences of my example table (i.e., [a - b] - [c - d]) in its Analysis Of Maximum Likelihood Parameter Estimates output. I was using GENMOD. I worked it out by hand and am coming up with the same answer that is being generated in the Parameter Estimates.
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
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.
Ready to level-up your skills? Choose your own adventure.