I have a dataset that contains the educational level(educ) for individuals that are in a certain industry(indnaics) for the years 2000-2014.
The educ variable contains non-numeric values see below:
I would like to replace these non-numeric values(educ) for numeric values(eduyears) according to the following scheme:
Is there any efficient way how I could replace this?
I have looked at using the replace command or using loops, but I can not seem to understand how I should do it. It could also be that I am looking in the wrong direction.
Is there anyone who could help me out?
Kind regards,
Tom
The educ variable contains non-numeric values see below:
Code:
etc.
year educ indnaics 2000 5+ years 6214 2000 4 years 6111 2000 5+ years 3399ZM 2000 2 years 622 2000 Grade 11 446Z 2000 1 year o 611M1 2000 5+ years 611M1 2000 Grade 12 493 2000 Grade 12 4451 2000 5+ years 6211 2000 4 years 712 2000 Grade 12 6111 2000 Grade 12 722Z 2000 Grade 11 6231 2000 Grade 12 813M 2000 Grade 12 5133Z 2000 1 year o 6231 2000 1 year o 334M2 2000 Grade 10 334M2 2000 4 years 5416 2000 5+ years 611M1 2000 4 years 611M1 2000 Grade 9 6241 2000 4 years 722Z 2000 Grade 12 23 2000 Grade 11 3MS 2000 4 years 713Z 2000 Grade 12 6212
Code:
Educational attainment eduYears N/A or no schooling 0 Nursery school to grade 4 4 Grade 5, 6, 7, or 8 8 Grade 9 9 Grade 10 10 Grade 11 11 Grade 12 12 1 year of college 13 2 years of college 14 3 years of college 15 4 years of college 16 5+ years of college 17
I have looked at using the replace command or using loops, but I can not seem to understand how I should do it. It could also be that I am looking in the wrong direction.
Is there anyone who could help me out?
Kind regards,
Tom
Comment