Dear Statalisters,
my control variables (CV) contain a high number of missing. For this reason, I will create a table reporting three columns: coefficients without CV, with CV (and a low number of observations) as well as with imputed values for the CV.
For the last column, I will impute the mean on these controls and include a dummy variable for imputation in the model.
I have already imputed the values with the command below. Note that IDescola means ID of the school.
Now I would like to create a dummy indicating if the observation (row) contains any imputation for the CV. In other others: My command should look all the variables in $controlvar2 and report 1 if it finds any imputed value for the observation/row.
Does anyone have any idea of how can I create this dummy?
Any advice would be highly appreciated!
Thanks in advance.
my control variables (CV) contain a high number of missing. For this reason, I will create a table reporting three columns: coefficients without CV, with CV (and a low number of observations) as well as with imputed values for the CV.
For the last column, I will impute the mean on these controls and include a dummy variable for imputation in the model.
I have already imputed the values with the command below. Note that IDescola means ID of the school.
Code:
foreach var of varlist $controlvar2 { egen mean = mean(`var'), by(IDescola) gen `var'imp = cond(missing(`var'), mean, `var') drop mean }
Does anyone have any idea of how can I create this dummy?
Any advice would be highly appreciated!
Thanks in advance.
Comment