Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating an unbalanced panel

    Hi I need help with the following :

    family ID myear edu
    A A1 1981 9
    A A2 1984 13
    A A3 1985 18
    A A4 1987 10
    A A5 1990 5

    myear is the year of marriage.


    I need to create an unbalanced (every ID is repeated from myear till 1990 ) panel data with a rolling sum variable at the ID-year level.


    For A2 in 1985, he is exposed to the 9 years education of A1 (not his own). This continues till A3 marries into family in 1985, and it changes to 27 till 1987 when A4 marries. It is 37 for 1987-88. It changes to 42 in 1990 with A5 marrying.

    (Similarly for every individual)

    The finaldata should look like this: (numerator is the variable I want and described above)
    family ID myear year dummy edu numerator denominator Avg exposure to edu by year
    A A1 81 81 0 9 0 0 .
    A A1 81 82 1 9 0 0 .
    A A1 81 83 0 9 0 0 .
    A A1 81 84 0 9 0 0 .
    A A1 81 85 0 9 0 0 .
    A A1 81 86 0 9 0 0
    A A1 81 87 1 9 0 0 .
    A A1 81 88 0 9 0 0 .
    A A1 81 89 0 9 0 0 .
    A A1 81 90 0 9 0 0 .
    A A2 84 84 0 13 9 1 9
    A A2 84 85 0 13 27 2 13.5
    A A2 84 86 1 13 27 2 13.5
    A A2 84 87 0 13 37 3 12.33333333
    A A2 84 88 1 13 37 3 12.33333333
    A A2 84 89 0 13 37 3 12.33333333
    A A2 84 90 0 13 42 4 10.5
    A A3 85 85 0 18 22 2 11
    A A3 85 86 0 18 22 2 11
    A A3 85 87 1 18 32 3 10.66666667
    A A3 85 88 0 18 32 3 10.66666667
    A A3 85 89 1 18 32 3 10.66666667
    A A3 85 90 0 18 37 4 9.25
    A A4 87 87 0 10 40 3 13.33333333
    A A4 87 88 0 10 40 3 13.33333333
    A A4 87 89 0 10 40 3 13.33333333
    A A4 87 90 1 10 45 4 11.25
    A A5 90 90 1 5 50 4 12.5
    Any idea how I can go about this? I have not understood how to tell stata that it is the sane household but you take women after my mnarriage, and make it a sum without including myself.

  • #2
    You didn't get a quick answer. You'll increase your chances of a useful answer by following the FAQ on asking questions - provide Stata code in code delimiters, readable Stata output, and sample data using dateaex.

    You probably want to use generate with sum and then correct afterwards for not including specific individuals or set those individuals to missing (in a new variable) and use generate with sum.

    Comment

    Working...
    X