Hi everyone! I'm fairly new to Stata & Statalist, so I apologize in advance if this question has already been asked. I did not find anything that could help me.

In my database the education is split into two different variables. The first variable is, how much education did the person complete in U. S here after USgfathereduc(categorical variable), while the second variable how many years of school did the person complete outside of the U.S.here after frgfathereduc(continuous variable). In addition a third variable indicates if the person receive his education - in the United States, outside the United States, or both hereafter wtrfathereduc.
I want to generate the total education of a person(toteduc). I have thought of this solution: First recoding the variable (frafathereduc )into a categorical variable, same as the first variable. After that i intended to generate toteduc that would equal the education in U.S if this results to be greater than the education outside the U.S and viceversa. In just a few observations it results that because of the fact that a missing value is considered as such a high value the condition greater/less doesnt fit.

recode frgfathereduc (0=0)(1/5=1) (6/8=2) (9/11=3) (12=4) (13/14=6) (15/16=7) (17/98=8)
tab frgfathereduc
replace frgfathereduc = . if frgfathereduc >=99
replace usfathereduc = . if usfathereduc >=99
list usfathereduc frgfathereduc if wtrfathereduc == 3
generate toteduc = 0
replace toteduc = usfathereduc if usfathereduc >= frgfathereduc
replace toteduc = frgfathereduc if frgfathereduc > usfathereduc
list toteduc usfathereduc frgfathereduc if wtrfathereduc == 3

For exemple in the observation 1680: USfathereduc= 8 and Frgfathereduc = 99(missing value) , instead of toteduc=8 it takes the value =99. Is there any possibility to correct for this problem?

I have uploaded codebox and the table of some observation.

I would really appreciate your help as i have struggled to find a solution. Thank u in advance. Lori