Hi everyone,
I am working with a panel data set, 4 waves, long format.
I created a dummy for missing values, if respondents participated in the wave, but not answered the question (dummy_`var')
Now I want to replace the missing values in each wave with the mean of the `var'[_n-1] and `var'[_n+1] if dummy_`var'==1
The variable names are: cesd numphy
This is the command I used:
foreach var in cesd numphy {
replace `var' = `var'[_n-1], `var'[_n+1]) / 2 if dummy_`var'==1
}
Somehow stata replies with "option cesd not allowed".
Does anyone have any idea what I did wrong and how I can make it work?
Kind Regards,
Lisa
I am working with a panel data set, 4 waves, long format.
I created a dummy for missing values, if respondents participated in the wave, but not answered the question (dummy_`var')
Now I want to replace the missing values in each wave with the mean of the `var'[_n-1] and `var'[_n+1] if dummy_`var'==1
The variable names are: cesd numphy
This is the command I used:
foreach var in cesd numphy {
replace `var' = `var'[_n-1], `var'[_n+1]) / 2 if dummy_`var'==1
}
Somehow stata replies with "option cesd not allowed".
Does anyone have any idea what I did wrong and how I can make it work?
Kind Regards,
Lisa
Comment