Hello everyone,

I have to use the variables lonely and ca_couple, calculate the proportions of individuals who feel lonely some of the time or often separately by whether they are living with a partner or not.

Then, I need to calculate the difference in the rate of "loneliness" between those two groups.
  • lonely takes 1 if the individual feels lonely sometimes or often. And 0 if the individual hardly ever or never feels lonely.
  • ca_couple takes 1 if living in couple, and 0 otherwise.
I tried the follwowing code:
Code:
tabulate lonely ca_couple, row col
local p_lonely_couple = 100*r(row1col1)/r(row1col2)
local p_lonely_single = 100*r(row2col1)/r(row2col2)
local diff_lonely = `p_lonely_single' - `p_lonely_couple'
display "Difference in the rate of loneliness: " %5.2f `diff_lonely'
Is a better way to do that? Thank you in advance. I obtain that in stata:

Code:
. local p_lonely_couple = 100*r(row1col1)/r(row1col2)

. local p_lonely_single = 100*r(row2col1)/r(row2col2)

. local diff_lonely = `p_lonely_single' - `p_lonely_couple'

. display "Difference in the rate of loneliness: " %5.2f `diff_lonely'
Difference in the rate of loneliness:     .
Best,

Michael