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
overlapping graph lines are obscuredHi there I would like to plot multiple lines on a graph, but often these lines overlap, in which ca…
Combining several variables in one datasetHi I am a political science student and quite new to stata I have used primary data from surveyxact…
How to make this graph with stack option?Dear all, I would like to make a graph as shown below. In my simple example, I calculated concentra…
Marking Answer Sheets using STATAI am trying to find a quicker way to mark answer sheets using stata (over 500 answer sheets with eac…
collinearity diagnostics for ordered logistic regressionDear researchers, I am trying to get the VIF after running the xtologit but it doesn't work with me…
Subscribe to:
Post Comments (Atom)
0 Response to Problem generating a new variable because of missing values
Post a Comment