We may be interested only in employment spells:
sel if empstat = 1. * Now EPISNO no longer counts spells. match files file = * /first = femp/last = lemp/by = pid. * A trick to identify the first and last records in each individual's block. compute empno = 1. if not femp empno = lag(empno)+1. exec. * Now empno counts employment spells.
If we wanted to generate this variable without throwing away non-job spells, this would work:
get file 'm:\empspells.sav'. match files file = * /first = fspell/last = lspell/by = pid. compute empno=0. if not fspell and empstat=1 empno=lag(empno)+1. if not fspell and empstat<>1 empno=lag(empno). freq empno.
With this sort of file we can find out, for instance, the duration and outcome of the job spell. Assume we want to know this for the first job spell: we need duration and endtype from that record and next state from the next record (if the first jobs-spell isn't the last recorded spell).
To refer to the next record in SPSS we need to sort in reverse order.
sort cases by pid, episno (d). do if empstat = 1 and empno = 1. . if lspell nextstat = 4. * Special value for `no next state observed'. . if not lspell nextstat = lag(empstat). end if. sort cases by pid, episno. * Restore the correct sort-order. temp. sel if empstat=1 and empno=1. freq nextstat.
Let's do a small check: if the spell's endtype is wJOBHIST then we should also observe the next spell in the corresponding wINDRESP observation, so in principle only wINDRESP endtypes will have a nextstat of 4, `not known':
temp. sel if empstat=1 and empno=1. cro nextstat by endtype.