gen years=10 if age>40 & !missing(age) & qualification==6
replace years=11 if age<=40 & qualification==6
replace years=13 if qualification==3
... etc
Some things to note:
= means assign a value
== means "is equal to"
use & for logical AND, | for logical OR
! means NOT
You need the:
& !missing(age)
because otherwise a missing age will match the expression ">40" (since in Stata, missing values are very very very large numbers)




Reply With Quote
