Hi, I have a variable called father's education (see below) which includes some missing values. I want to replace the missing values with the average father's education calculated by using respondents who do not have missing values in father's education. My codes are as follows, but they do not work. Can anyone help me? Thanks!

Code:
egen mean_feduyear=mean(feduyear) if feduyear!=. tab mean_feduyear replace feduyear = mean_feduyear if missing(feduyear) or replace feduyear = mean_feduyear if feduyear==.
Comment