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
Related Posts with Problem generating a new variable because of missing values
Help with my codeHi to everyone, I have a problem in stata. I am writing this code: gen end_date4=end_date (end_d…
PoissonHi Dear, I have a question. My dependent variable is a count variable. I want to choose between Pois…
Having Y-axis in exponent scalesDear Statalist, I've been looking at the graphs manual and couldn't find an answer to this. I am r…
how can I calculate indirect effect in GSEM with different link?Hello everyone, I need some help, when I ran the GSEM model with different links , I do not know h…
strs ERROR.Could you please help me to solve this problem when running strs command? I have tried everything an…
Subscribe to:
Post Comments (Atom)
0 Response to Problem generating a new variable because of missing values
Post a Comment