Hi Statalist members,

I am working with survey balanced panel data covering 32 waves. I am analyzing the effect of marital status on life satisfaction. Currently I am trying to plot the mean life satisfaction for all individuals for the years surrounding the marriage. I am not sure if this is regression discontinuity or can be graphed with 'twoway'. I assume I need to transform the years into some kind of categorical variable which takes positive values (after marriage) and negative values (before marriage) - therefore creating a threshold (example is the screenshot below).

So far I have calculated the mean of life satisfaction and transformed the marital status variable into dummy - married and single. Also I want to observe that effect controlling for the other variables. Any ideas on how to proceed ?

bysort pid (age): egen SM = mean(lifesatis)
bysort age: egen SM_ = mean(SM)
label var SM_ "Satisfaction with life"

Kind regards,
Gabriela

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float SM_ long pid byte(lifesatis marstatus sex newd11105) float(log_HH_income log_educ) int age byte(ppl_HH children_HH region sathealth empl_level) int syear
6.972734 101  8 1 1 1 10.289362   2.70805 54 3 0 1  8 1 1984
6.968498 101  8 1 1 1  9.700759   2.70805 55 2 0 1  8 1 1985
6.989519 101 10 1 1 1 10.054663   2.70805 56 2 0 1  7 1 1986
7.001862 101  8 1 1 1  8.497194   2.70805 57 2 0 1  5 1 1987
7.019915 101  8 1 1 1  9.633514   2.70805 58 2 0 1  8 1 1988
7.040678 101  8 1 1 1  9.845593   2.70805 59 2 0 1  7 1 1989
7.322013 101  . . . .         .         .  . . . .  . . 1990
7.322013 101  . . . .         .         .  . . . .  . . 1991
7.322013 101  . . . .         .         .  . . . .  . . 1992
7.322013 101  . . . .         .         .  . . . .  . . 1993
7.322013 101  . . . .         .         .  . . . .  . . 1994
7.322013 101  . . . .         .         .  . . . .  . . 1995
7.322013 101  . . . .         .         .  . . . .  . . 1996
7.322013 101  . . . .         .         .  . . . .  . . 1997
7.322013 101  . . . .         .         .  . . . .  . . 1998
7.322013 101  . . . .         .         .  . . . .  . . 1999
7.322013 101  . . . .         .         .  . . . .  . . 2000
7.322013 101  . . . .         .         .  . . . .  . . 2001
7.322013 101  . . . .         .         .  . . . .  . . 2002
7.322013 101  . . . .         .         .  . . . .  . . 2003
7.322013 101  . . . .         .         .  . . . .  . . 2004
7.322013 101  . . . .         .         .  . . . .  . . 2005
7.322013 101  . . . .         .         .  . . . .  . . 2006
7.322013 101  . . . .         .         .  . . . .  . . 2007
7.322013 101  . . . .         .         .  . . . .  . . 2008
7.322013 101  . . . .         .         .  . . . .  . . 2009
7.322013 101  . . . .         .         .  . . . .  . . 2010
7.322013 101  . . . .         .         .  . . . .  . . 2011
7.322013 101  . . . .         .         .  . . . .  . . 2012
7.322013 101  . . . .         .         .  . . . .  . . 2013
7.322013 101  . . . .         .         .  . . . .  . . 2014
7.322013 101  . . . .         .         .  . . . .  . . 2015
7.097521 102  8 1 2 1 10.289362 2.1972246 44 3 0 1  7 3 1984
7.082045 102  8 1 2 1  9.700759 2.1972246 45 2 0 1  8 3 1985
7.067087 102  9 1 2 1 10.054663 2.1972246 46 2 0 1  7 3 1986
7.044371 102  8 1 2 1  8.497194 2.1972246 47 2 0 1  8 3 1987
7.040834 102  9 1 2 1  9.633514 2.1972246 48 2 0 1  8 3 1988
7.021253 102 10 1 2 1  9.845593 2.1972246 49 2 0 1 10 3 1989
7.322013 102  . . . .         .         .  . . . .  . . 1990
7.322013 102  . . . .         .         .  . . . .  . . 1991
7.322013 102  . . . .         .         .  . . . .  . . 1992
7.322013 102  . . . .         .         .  . . . .  . . 1993
7.322013 102  . . . .         .         .  . . . .  . . 1994
7.322013 102  . . . .         .         .  . . . .  . . 1995
7.322013 102  . . . .         .         .  . . . .  . . 1996
7.322013 102  . . . .         .         .  . . . .  . . 1997
7.322013 102  . . . .         .         .  . . . .  . . 1998
7.322013 102  . . . .         .         .  . . . .  . . 1999
7.322013 102  . . . .         .         .  . . . .  . . 2000
7.322013 102  . . . .         .         .  . . . .  . . 2001
7.322013 102  . . . .         .         .  . . . .  . . 2002
7.322013 102  . . . .         .         .  . . . .  . . 2003
7.322013 102  . . . .         .         .  . . . .  . . 2004
7.322013 102  . . . .         .         .  . . . .  . . 2005
7.322013 102  . . . .         .         .  . . . .  . . 2006
7.322013 102  . . . .         .         .  . . . .  . . 2007
7.322013 102  . . . .         .         .  . . . .  . . 2008
7.322013 102  . . . .         .         .  . . . .  . . 2009
7.322013 102  . . . .         .         .  . . . .  . . 2010
7.322013 102  . . . .         .         .  . . . .  . . 2011
7.322013 102  . . . .         .         .  . . . .  . . 2012
7.322013 102  . . . .         .         .  . . . .  . . 2013
7.322013 102  . . . .         .         .  . . . .  . . 2014
7.322013 102  . . . .         .         .  . . . .  . . 2015
7.278812 103  8 2 1 3 10.289362  2.484907 21 3 0 1  8 1 1984
7.251355 103  8 2 1 1   9.89278  2.484907 22 1 0 1 10 1 1985
7.226252 103  7 2 1 1  9.326166  2.484907 23 1 0 1  9 1 1986
7.215858 103  7 2 1 1  10.35974  2.484907 24 2 0 1 10 1 1987
7.322013 103  . . . .         .         .  . . . .  . . 1988
7.322013 103  . . . .         .         .  . . . .  . . 1989
7.322013 103  . . . .         .         .  . . . .  . . 1990
7.322013 103  . . . .         .         .  . . . .  . . 1991
7.322013 103  . . . .         .         .  . . . .  . . 1992
7.322013 103  . . . .         .         .  . . . .  . . 1993
7.322013 103  . . . .         .         .  . . . .  . . 1994
7.322013 103  . . . .         .         .  . . . .  . . 1995
7.322013 103  . . . .         .         .  . . . .  . . 1996
7.322013 103  . . . .         .         .  . . . .  . . 1997
7.322013 103  . . . .         .         .  . . . .  . . 1998
7.322013 103  . . . .         .         .  . . . .  . . 1999
7.322013 103  . . . .         .         .  . . . .  . . 2000
7.322013 103  . . . .         .         .  . . . .  . . 2001
7.322013 103  . . . .         .         .  . . . .  . . 2002
7.322013 103  . . . .         .         .  . . . .  . . 2003
7.322013 103  . . . .         .         .  . . . .  . . 2004
7.322013 103  . . . .         .         .  . . . .  . . 2005
7.322013 103  . . . .         .         .  . . . .  . . 2006
7.322013 103  . . . .         .         .  . . . .  . . 2007
7.322013 103  . . . .         .         .  . . . .  . . 2008
7.322013 103  . . . .         .         .  . . . .  . . 2009
7.322013 103  . . . .         .         .  . . . .  . . 2010
7.322013 103  . . . .         .         .  . . . .  . . 2011
7.322013 103  . . . .         .         .  . . . .  . . 2012
7.322013 103  . . . .         .         .  . . . .  . . 2013
7.322013 103  . . . .         .         .  . . . .  . . 2014
7.322013 103  . . . .         .         .  . . . .  . . 2015
7.019915 201 10 . 2 1   7.90802  2.397895 58 3 0 1 10 3 1984
7.040678 201 10 . 2 1  7.805475  2.397895 59 2 0 1  5 3 1985
7.062017 201  9 . 2 1  8.028781  2.397895 60 2 0 1  9 3 1986
7.081214 201 10 . 2 1         .  2.397895 61 1 0 1 10 3 1987
end
label values lifesatis p11101
label def p11101 10 "[10] Completely satisfied    10", modify
label values marstatus d11104
label def d11104 1 "[1] Married        1", modify
label def d11104 2 "[2] Single         2", modify
label values sex d11102ll
label def d11102ll 1 "[1] Male           1", modify
label def d11102ll 2 "[2] Female         2", modify
label values region l11102
label def l11102 1 "[1] West-Germany   1", modify
label values sathealth m11125
label def m11125 10 "[10] Completely satisfied    10", modify
label values empl_level e11103
label def e11103 1 "[1] Full Time      1", modify
label def e11103 3 "[3] Not Working    3", modify