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
Support: most efficient way to enter dataHi everyone, I am a total newbie to Stata, so perhaps some of you can help me with this issue: For…
Easier way to get casewise statistics using tabstat?Hi, I need a command/code that help me to get casewise descriptive statistics using "tabstat" witho…
conflicting results with command ivprobit and marginsHi all! When I ran ivprobit, I got positive and significant coefficient for my endogenous independen…
Questions about Logit regression applicable in my research design.Hello, everyone. I am not new to use Statalist, but this is the first time I am not sure I find an …
Pooled OLS and Random EffectsHello everyone, Was just concerned as I have a set of panel data obvservations, and when running reg…
Subscribe to:
Post Comments (Atom)
0 Response to Problem generating a new variable because of missing values
Post a Comment