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
Drop observations based on value of previous observationHi all, I have a panel dataset on productivity. The variables are as follows: activity = the activi…
t-test output table by groupHi all, It may seem a silly question but I'm struggling to create a table with a t test like this o…
Counts for multiple variablesHello, I am analyzing a hospital dataset which provides demographic, diagnostic, and procedural data…
create and call subroutine from the same .do fileHi, I have a large piece of code that I would like to break down in several smaller pieces of code …
Gen. new variables based on values for multiple existing variables, TSCS dataDear members, I have put together a data-set with information about military alliances btw states i…
Subscribe to:
Post Comments (Atom)
0 Response to Problem generating a new variable because of missing values
Post a Comment