Hi all,
I have long format data in which respondents have varying amounts of observations. I am trying to pull data forward, such that if someone is missing on a variable in wave 7, it becomes equal to their wave 6 value. I am using the following code
I have made a copy of each variable in my dataset in order to keep the original variable. With this code, many cases are working as expected. However, variables with extended missing (ex: .d) seem to be misbehaving. Take the following example. "rdiab" is .d in wave 11 and 1 in wave 12. After I create my copy variable and run the previous code, .d at wave 11 becomes "." What is happening? There is no _n - 1 observation in this case. Why is the observation not retaining its extended missing value?
I have long format data in which respondents have varying amounts of observations. I am trying to pull data forward, such that if someone is missing on a variable in wave 7, it becomes equal to their wave 6 value. I am using the following code
Code:
foreach v of varlist *_copy { by hhidpn: replace `v' = `v'[_n-1] if missing(`v') }
Code:
+--------------------------------------------------------------------+ | hhidpn wave riwstat rdiab rdiab_~y mean_e~c dementia | |--------------------------------------------------------------------| 46629. | 85001040 11 1 .d . 12 1 | 46630. | 85001040 12 1 1 1 12 1 | +--------------------------------------------------------------------+
Comment