Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Data management, years of schooling


From   Ronnie Babigumira <[email protected]>
To   [email protected]
Subject   st: Data management, years of schooling
Date   Wed, 04 Feb 2009 04:06:25 +0100

Dear List
I have an interesting data management problem. My data look like this
hhid	hi_educ
1	11
2	21
3	17
4	16
5	24
6	31
7	32
8	13
9	22

Where hi_educ is the highest level of education for household. From this I would like to extract the number of years of schooling.

Now, for values below 17, the years of schooling is the last digit
for values between 21 and 24, it is 7 + the last digit
for values between 31 and 35 it is 11 + the last digit

What I would like to end up with is something like this

hhid	hi_educ	years
1	11	1
2	21	8
3	17	7
4	16	6
5	24	11
6	31	12
7	32	13
8	13	3
9	22	9

I am stuck here
gen str3 test = ""
replace test  = substr(string(hi_educ), -1,.) if inrange(hi_educ,11,17)

I would appreciate any help

Ronnie
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index