I am using annual survey responses on marital status from a panel study (for each partner in a couple - married/cohabitation) for my analysis. Around 0.8% of responses are missing and I want to replace the missing values with lagged values (for the given partner) or those of the other partner if these are also missing - it is not uncommon that only one in the couple answers this question. Sometimes individuals in a couple miss answering this question in a given year(s). Is this approach reasonable, particularly if there are lagged values and future values and these are the same?
I'm sure my draft code does not achieve what I want it to, so help here is appreciated (mrcurr1 - marital status of male partner); mrcurr2 - marital status of female partner)
Code:
bys id (wave): replace mrcurr1 = L.mrcurr1 if missing(mrcurr1) bys id (wave): replace mrcurr1 = L.mrcurr2 if missing(mrcurr1) // in case the current wave response is missing for both bys id (wave): replace mrcurr2 = L.mrcurr2 if missing(mrcurr2) bys id (wave): replace mrcurr2 = L.mrcurr1 if missing(mrcurr2)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long(id p_id) byte(wave mrcurr1 mrcurr2) 11 61 8 . 2 11 61 12 . 2 11 61 13 . 2 11 61 14 . 2 11 61 15 . 2 11 61 16 . 2 11 61 17 . 2 11 61 18 . 2 13 60 12 . 1 13 60 13 . 1 13 60 14 . 1 13 60 15 . 1 13 60 16 . 1 13 60 17 . 1 13 60 18 . 1 16 64 8 2 . 16 64 9 2 . 16 64 10 2 . 16 64 11 1 . 16 64 12 1 . 16 64 13 1 . 16 64 14 1 . 16 64 15 1 . 16 64 16 1 . 16 64 17 1 . 16 64 18 1 . 23 24 6 . . 23 24 7 . . 23 24 8 . . 23 24 9 . . 23 24 10 . . 23 24 11 . . 23 24 12 . . end
0 Response to Replace missing values with those of previous values or those of the partner
Post a Comment