Hi everyone,
I have been trying to create a variable measuring the number of years spent in unemployment by each individual in my sample. In the dataset I am using I have information about individuals' work histories including the starting - "anini*" - and ending - "anfin*" year of the last 11 jobs. Other information concern the year one has completed education - "tintanno". Because I am focusing on the 15 years after one has exited the educational system, I have created a variable "span" as the sum of "tintanno" and 15.
This is the syntax I have used so far to create the variable for the number of years spent in unemployment:
gen durunemp = .
forval i = 1/10 {
local j = `i' +1
replace durunemp = ((anini`j' - anfin`i') + (anini1 - tintanno)) ///
if anfin`i' != anini`j' ///
& anfin`i' != . ///
& anini`j'<= span ///
& anfin`i'<= span ///
& anini`i' > tintanno
}
The logic behind it is that the number of years spent in unemployment - in the considered span of 15 years - should be the sum of 1)the difference between the year a new job starts and the year the previous one ends and 2)the difference between the year the respondent got the first job and the year they completed education. For some reason, it seems like this syntax doesn't take into account the 2 part of the equation (anini1-tintanno).
Thank you in advance for your help!
I have been trying to create a variable measuring the number of years spent in unemployment by each individual in my sample. In the dataset I am using I have information about individuals' work histories including the starting - "anini*" - and ending - "anfin*" year of the last 11 jobs. Other information concern the year one has completed education - "tintanno". Because I am focusing on the 15 years after one has exited the educational system, I have created a variable "span" as the sum of "tintanno" and 15.
This is the syntax I have used so far to create the variable for the number of years spent in unemployment:
gen durunemp = .
forval i = 1/10 {
local j = `i' +1
replace durunemp = ((anini`j' - anfin`i') + (anini1 - tintanno)) ///
if anfin`i' != anini`j' ///
& anfin`i' != . ///
& anini`j'<= span ///
& anfin`i'<= span ///
& anini`i' > tintanno
}
The logic behind it is that the number of years spent in unemployment - in the considered span of 15 years - should be the sum of 1)the difference between the year a new job starts and the year the previous one ends and 2)the difference between the year the respondent got the first job and the year they completed education. For some reason, it seems like this syntax doesn't take into account the 2 part of the equation (anini1-tintanno).
Thank you in advance for your help!
Comment