I have a cell variable with 13000 rows and 11 columns. For instance:
C1 c2 c3 c4 c5 c6 c7 A={22 1988 1992 2001 2001 [] [] 23 1983 1988 [] [] [] [] 29 1983 1985 1988 1991 2000 2003}
C1 is a code for an individual; c2 is the year the individual first is in the sample; c3 is the year he/she leaves. C4 is the year the individual comes back to the sample; c5 is the year the individual goes off again; and so on. The sample period is from 1983 to 2013. I can have individuals that appear in one year, leave in other and never appear again; as others may be constantly on and off the sample. I am trying to get the following variable:
- A double variable with 3 rows, ordered by year, indicating for each year and for each individual the number of years the individual is in the sample in year x.
- If the indiviual leaves the period for at least one year and comes back again , I start the count from one (number of years the individual is in the sample).
- If the individual is less than 3 years in the sample don't consider it for the count .
B=[1983 23 1 1983 29 11984 23 21984 29 21985 23 31985 29 31986 23 41987 23 51988 22 11988 23 61988 29 11989 22 21989 29 21990 22 3 1990 29 31991 22 41991 29 41992 22 5…2001 29 22002 29 32003 29 4]
Can someone help me? Thank you.
Best Answer