I run a fixed effects panel regression on survey data with missing values at my regressors (and DV). Since missings make about 35% in my personal data, it's time to deal with them. First option I found is dummy variable adjustment. I am aware of some drawbacks of the method in general. In this post I am interested in the code implementation.

I followed the procedure from this site: https://ies.ed.gov/ncee/pubs/20090049/section_3a.asp

My setup is very similar to this MWE:

Code:
* load data
use http://www.stata-press.com/data/r13/nlswork

* set panel structure
xtset idcode year
* 28534 obs, missing data e.g. union 9296
mdesc

* fixed effects regression (automatically uses 13797 complete cases)
quietly xtreg ln_wage c.wks_ue##c.wks_ue##i.occ_code union age, fe
margins, dydx(wks_ue)

* dummy variable adjustment to deal with missing data in regressors
gen D=0
replace D=1 if wks_ue==.
replace wks_ue=0 if wks_ue==.

* run FE again (now 19156 obs are used)
quietly xtreg ln_wage c.wks_ue##c.wks_ue##i.occ_code##D union age, fe
margins, dydx(wks_ue)
First, my question is whether it is correct to use the dummy D once in the interaction (since the regressor with missing data is a quadratic term). The subsequent question is, if there a way to automate this procedure? Since I have have 15 variables in my model, and I would like to use DVA for 5 of them. Thank you