I am working with spell data that looks like this:
I have to calculate unemployment duration, measured as the difference between the beginning date of unemployment erw == 11 and the beginning date of the immediate next employment spell (erw ==101). In essence, for each unemployment spell, I need to find the duration between the beginning date of that unemployment spell to the beginning date of the next employment spell. In this example, for nspell 3, (mod of 17953 - 18251), for nspell 4 (mod of 18206 - 18251), for spell 5 (mod of 18211 - 18251).
How do I code this?
Code:
* Example generated by -dataex-. For more info, type help dataex clear input float(persnr_siab nspell) int(erwstat begorig endorig) float(episode_length episode_length_M) 2 1 101 17167 17531 365 11.991786 2 2 101 17532 17897 366 12.02464 2 3 11 17953 18205 253 8.312115 2 4 11 18206 18210 5 .16427104 2 5 11 18211 18227 17 .55852157 2 6 101 18251 18262 12 .3942505 2 7 101 18876 18992 117 3.8439424 end format %tdD_m_CY begorig format %tdD_m_CY endorig label values erwstat erwstat_en label def erwstat_en 11 "11 ALG Unemployment benefits", modify label def erwstat_en 101 "101 Employees liable to social security without special characteristics", modify label var persnr_siab "Individual ID (simplified)" label var nspell "Non-parallel spell counter" label var erwstat "Employment status" label var begorig "Original start date" label var endorig "Original end date" label var episode_length "Length/duration of spell" label var episode_length_M "Monthly length/duration of spell"
I have to calculate unemployment duration, measured as the difference between the beginning date of unemployment erw == 11 and the beginning date of the immediate next employment spell (erw ==101). In essence, for each unemployment spell, I need to find the duration between the beginning date of that unemployment spell to the beginning date of the next employment spell. In this example, for nspell 3, (mod of 17953 - 18251), for nspell 4 (mod of 18206 - 18251), for spell 5 (mod of 18211 - 18251).
How do I code this?
Comment