BookmarkSubscribeRSS Feed
N8
Obsidian | Level 7 N8
Obsidian | Level 7

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

2 REPLIES 2
PaigeMiller
Diamond | Level 26

What SAS PROC are you using?

 

Some SAS PROCs have the LSMESTIMATE statement, this is what you need.

--
Paige Miller
N8
Obsidian | Level 7 N8
Obsidian | Level 7

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. 

CFC_SAS_Communities_400x225.jpgCFC_SAS_Communities_400x225.jpg

Call for content now open!

It's your turn to help shape SAS Innovate 2027. Share your expertise and inspire the SAS community.

Submit your proposal →

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 1629 views
  • 1 like
  • 2 in conversation