Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Counting shifts (and duration) in labor market status

From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Counting shifts (and duration) in labor market status
Date   Tue, 29 Apr 2003 22:09:52 +0100


I have monthly labor market status observations: i.e each person is
through 12 months with the following information: 1 employed, 2
unemployed, 3
out of labor force.

obs   Jan   Feb   Mar   Apr ................
1     2     2     1     1
2     1     1     1     2
3     1     2     2     3

I am now looking for a smart way of counting number of times each
person fell
into unemployment, i.e. a shift from 1 to 2 (or maybe even 3 to 2).
Also how to
count the duration of each unemployment spell i.e. how many months
does every
spell last.

I assume that many have encountered this issue before me and thought
of a smart
way to do it.


1. -reshape-

You need first to -reshape- to long. Your data structure problem is
described at

but you need, before that even, to -rename- those month 

(Stata 8) 

local i = 1 
foreach v of var Jan-Dec { 
        rename `v' m`i++' 


(Stata 7) 

for var Jan-Dec \ new m1-m12 : rename X Y 


(-renvars-, STB-60) 

renvars Jan-Dec \ m1-m12  

Now you 

reshape long m , i(obs) j(time) 

2. -tsset- 

Then you can 

tsset obs time 

3. -tsspell-

and download -tsspell- from SSC 

(Stata 8 or updated Stata 7) 

ssc inst tsspell


tsspell, fcond(m == 2 & L.m != 2) 


tsspell m 

and look at the resulting variables. The help file for -tsspell- 
gives several examples. 

[email protected]
*   For searches and help try:

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