Announcement

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

  • How to create a panel of individuals observed for successive waves

    Hi there,

    I am working with a panel data of 3 waves (3, 4, and 5). I want to analyze and compare characteristics of individuals observed for successive survey waves. So, I want to create a panel for individuals observed for successive waves, i.e, a panel for those observed for wave 3 and 4; and for those observed for waves 4 and 5. My data structure is as follows:

    Code:
    * Example generated by -dataex-. To install: ssc    install    dataex
    clear
    input float hhid long pid float(wave pcy)
    300000 304623 3  7.468816
    300000 304624 3  7.468816
    300000 304623 4  8.191607
    300000 304623 5  8.257506
    300000 304624 4  8.191607
    300000 304624 5  8.257506
    300001 305268 5  7.597524
    300001 305269 4    9.4975
    300001 620952 3 8.5963335
    300001 305268 3 8.5963335
    300001 305268 4  7.684784
    300001 620952 4  7.684784
    300001 305269 5  9.610334
    300001 305250 5  7.597524
    300001 305250 4  7.684784
    300001 305269 3 8.5963335
    300001 305249 5  7.597524
    300001 305249 3 8.5963335
    300001 305250 3 8.5963335
    300001 620952 5  7.597524
    300001 305249 4  7.684784
    300002 319161 4  6.932395
    300002 319161 5  7.663094
    300002 319161 3  6.956741
    300003 402779 4  6.825533
    300003 309522 3         .
    300003 305291 4  7.828432
    300003 583034 5  8.317959
    300003 402779 5  6.854149
    300003 305291 3         .
    300003 582536 5  6.854149
    300003 309522 5         .
    300003 305291 5  6.854149
    300003 583034 3         .
    300003 582536 4  7.828432
    300003 582536 3         .
    300003 309522 4         .
    300003 583034 4  7.835113
    300003 402779 3         .
    300004 302034 5  9.338085
    300004 302034 3 9.2136755
    300004 302034 4  9.330969
    300005 303039 4  7.448096
    300005 303039 5  6.725547
    300005 303039 3  9.211509
    300006 305649 3  7.071443
    300006 311353 4    7.9242
    300006 311353 5         .
    300006 311353 3  7.071443
    300006 305649 5   7.90295
    300006 305649 4  7.922594
    300007 407393 4         .
    300007 407393 3         .
    300007 407397 3         .
    300007 407397 5  6.300319
    300007 407397 4         .
    300007 407393 5  7.196711
    300008 410590 5  6.955804
    300008 321630 5  6.955804
    300008 321630 4   6.84182
    300008 410590 4   6.84182
    300008 319052 4   6.84182
    300008 319052 5  7.327477
    300008 321631 3  7.437262
    300008 319052 3  7.437262
    300008 321631 5  6.955804
    300008 410590 3  7.437262
    300008 321631 4   6.84182
    300008 321630 3  7.437262
    300009 301903 5  9.647812
    300009 301903 3  8.786242
    300009 301903 4 10.103908
    300010 409493 4  7.346483
    300010 620604 3         .
    300010 409494 5  7.333076
    300010 381188 5  6.345164
    300010 381188 3         .
    300010 409494 3         .
    300010 409493 5  7.333076
    300010 409493 3         .
    300010 620604 4   7.47222
    300010 381188 4   7.47222
    300010 620604 5   7.30386
    300010 409494 4  7.346483
    300011 470329 3         .
    300011 319825 3         .
    300011 319824 3         .
    300011 470329 5         .
    300011 319823 5         .
    300011 319823 3         .
    300011 319825 5         .
    300011 319823 4         .
    300011 319825 4         .
    300011 470329 4         .
    300011 319824 4         .
    300011 319824 5         .
    300012 720804 4   7.06202
    300012 315004 3  6.578661
    300012 720802 3  6.578661
    300012 408582 3  6.578661
    300012 407674 4  7.120476
    300012 315004 5  5.729524
    300012 315006 5         .
    300012 720803 4   7.06202
    300012 720805 3  6.578661
    300012 408583 5  6.731416
    300012 408582 5  6.731416
    300012 315004 4   7.06202
    300012 720804 3  6.578661
    300012 720802 5  5.729524
    300012 720804 5         .
    300012 315005 4   7.06202
    300012 720805 5  5.729524
    300012 720802 4   7.06202
    300012 408583 3  6.578661
    300012 720805 4   7.06202
    300012 407674 5  6.731416
    300012 315005 5  5.729524
    300012 720803 3  6.578661
    300012 315005 3  6.578661
    300012 408583 4  7.120476
    300012 407674 3  6.578661
    300012 408582 4  7.120476
    300012 315006 3         .
    300012 720803 5  5.729524
    300012 315006 4         .
    300013 317604 4  5.165946
    300013 406032 5  6.362245
    300013 406047 4  5.165946
    300013 406032 4  5.165946
    300013 317604 5  6.362245
    300013 406032 3  7.121995
    300013 406047 5  6.362245
    300013 406047 3  7.121995
    300013 317604 3  7.121995
    300014 722781 5         .
    300014 722782 5  8.229511
    300014 315641 5  7.850154
    300014 408664 4  7.921302
    300014 722781 4         .
    300014 408615 5  8.229511
    300014 722782 4  7.921302
    300014 315604 4         .
    300014 722781 3         .
    300014 408664 3  7.744731
    300014 408615 3  7.744731
    300014 315605 3         .
    300014 408605 4  7.921302
    300014 315604 5         .
    300014 315641 3  7.744731
    300014 315605 4         .
    300014 315637 4  7.921302
    300014 408605 3  7.744731
    300014 315641 4  7.921302
    300014 315605 5         .
    300014 408605 5  7.850154
    300014 408664 5  7.850154
    300014 722782 3  7.744731
    300014 315637 3  7.744731
    300014 408615 4  7.921302
    300014 315604 3  7.744731
    300014 315637 5  7.850154
    300015 304188 3  7.834811
    300015 304185 3  7.834811
    300015 730216 5         .
    300015 405518 4   6.88641
    300015 730216 3  7.834811
    300015 304185 5  7.958376
    300015 304187 4         .
    300015 405518 5  7.958376
    300015 730216 4         .
    300015 304187 5         .
    300015 405518 3  7.834811
    300015 304185 4   6.88641
    300015 304187 3         .
    300015 304188 5  7.958376
    300015 304188 4   6.88641
    300016 630586 5  5.179518
    300016 409643 3  5.737711
    300016 409643 4  6.624718
    300016 409642 5  7.942819
    300016 316342 4  6.624718
    300016 409642 3  5.737711
    300016 316343 3  5.737711
    300016 316343 5  5.179518
    300016 630586 4  6.624718
    300016 316342 5  5.179518
    300016 409641 3  5.737711
    300016 316341 4  6.624718
    300016 316343 4  6.624718
    300016 316342 3  5.737711
    300016 409643 5  5.179518
    300016 316341 3  5.737711
    300016 409641 4  6.624718
    300016 409642 4   7.42242
    300016 630586 3  5.737711
    300016 316341 5  6.985971
    300016 409641 5  5.179518
    300017 306543 4  6.571434
    300017 403621 3   6.13646
    end
    label var pid "Person identifier" 
    label var pcy "log per capita household income"
    My xtdes command produces the following output:

    xtdes

    pid: 301011, 301012, ..., 799992 n = 59558
    wave: 3, 4, ..., 5 T = 3
    Delta(wave) = 1 unit
    Span(wave) = 3 periods
    (pid*wave uniquely identifies each observation)

    Distribution of T_i: min 5% 25% 50% 75% 95% max
    1 1 2 3 3 3 3

    Freq. Percent Cum. Pattern

    40558 68.10 68.10 111
    9301 15.62 83.72 ..1
    9193 15.44 99.15 .11
    207 0.35 99.50 11.
    193 0.32 99.82 1.1
    63 0.11 99.93 1..
    43 0.07 100.00 .1.

    59558 100.00 XXX

    Many thanks in anticipation.

  • #2
    What you want is not clear to me.

    You have many panels (people) observed in waves 345, some observed in 34 only, some observed in 45 only, and so on. Do you want to restrict analyses only to incomplete panels, say 34 and 45?

    Comment


    • #3
      Nick Cox, Thanks for the feedback, and sorry for the confusion. What I am trying to do is create a panel of individuals observed for at least 2 consecutive waves., i.e 34, 345, or 45. Thanks very much.

      Comment


      • #4
        There is a risk here of confusion over terminology.

        As I understand it, a panel is an individual (person, firm, whatever) observed over time. A panel dataset typically consists of several panels observed over time. You want a smaller panel dataset.

        Here is one way to subdivide. The principle and the technique should be clear, but if more detail is needed, check out https://journals.sagepub.com/doi/pdf...36867X20909698



        Code:
        * Example generated by -dataex-. To install: ssc    install    dataex
        clear
        input float hhid long pid float(wave pcy)
        300000 304623 3  7.468816
        300000 304624 3  7.468816
        300000 304623 4  8.191607
        300000 304623 5  8.257506
        300000 304624 4  8.191607
        300000 304624 5  8.257506
        300001 305268 5  7.597524
        300001 305269 4    9.4975
        300001 620952 3 8.5963335
        300001 305268 3 8.5963335
        300001 305268 4  7.684784
        300001 620952 4  7.684784
        300001 305269 5  9.610334
        300001 305250 5  7.597524
        300001 305250 4  7.684784
        300001 305269 3 8.5963335
        300001 305249 5  7.597524
        300001 305249 3 8.5963335
        300001 305250 3 8.5963335
        300001 620952 5  7.597524
        300001 305249 4  7.684784
        300002 319161 4  6.932395
        300002 319161 5  7.663094
        300002 319161 3  6.956741
        300003 402779 4  6.825533
        300003 309522 3         .
        300003 305291 4  7.828432
        300003 583034 5  8.317959
        300003 402779 5  6.854149
        300003 305291 3         .
        300003 582536 5  6.854149
        300003 309522 5         .
        300003 305291 5  6.854149
        300003 583034 3         .
        300003 582536 4  7.828432
        300003 582536 3         .
        300003 309522 4         .
        300003 583034 4  7.835113
        300003 402779 3         .
        300004 302034 5  9.338085
        300004 302034 3 9.2136755
        300004 302034 4  9.330969
        300005 303039 4  7.448096
        300005 303039 5  6.725547
        300005 303039 3  9.211509
        300006 305649 3  7.071443
        300006 311353 4    7.9242
        300006 311353 5         .
        300006 311353 3  7.071443
        300006 305649 5   7.90295
        300006 305649 4  7.922594
        300007 407393 4         .
        300007 407393 3         .
        300007 407397 3         .
        300007 407397 5  6.300319
        300007 407397 4         .
        300007 407393 5  7.196711
        300008 410590 5  6.955804
        300008 321630 5  6.955804
        300008 321630 4   6.84182
        300008 410590 4   6.84182
        300008 319052 4   6.84182
        300008 319052 5  7.327477
        300008 321631 3  7.437262
        300008 319052 3  7.437262
        300008 321631 5  6.955804
        300008 410590 3  7.437262
        300008 321631 4   6.84182
        300008 321630 3  7.437262
        300009 301903 5  9.647812
        300009 301903 3  8.786242
        300009 301903 4 10.103908
        300010 409493 4  7.346483
        300010 620604 3         .
        300010 409494 5  7.333076
        300010 381188 5  6.345164
        300010 381188 3         .
        300010 409494 3         .
        300010 409493 5  7.333076
        300010 409493 3         .
        300010 620604 4   7.47222
        300010 381188 4   7.47222
        300010 620604 5   7.30386
        300010 409494 4  7.346483
        300011 470329 3         .
        300011 319825 3         .
        300011 319824 3         .
        300011 470329 5         .
        300011 319823 5         .
        300011 319823 3         .
        300011 319825 5         .
        300011 319823 4         .
        300011 319825 4         .
        300011 470329 4         .
        300011 319824 4         .
        300011 319824 5         .
        300012 720804 4   7.06202
        300012 315004 3  6.578661
        300012 720802 3  6.578661
        300012 408582 3  6.578661
        300012 407674 4  7.120476
        300012 315004 5  5.729524
        300012 315006 5         .
        300012 720803 4   7.06202
        300012 720805 3  6.578661
        300012 408583 5  6.731416
        300012 408582 5  6.731416
        300012 315004 4   7.06202
        300012 720804 3  6.578661
        300012 720802 5  5.729524
        300012 720804 5         .
        300012 315005 4   7.06202
        300012 720805 5  5.729524
        300012 720802 4   7.06202
        300012 408583 3  6.578661
        300012 720805 4   7.06202
        300012 407674 5  6.731416
        300012 315005 5  5.729524
        300012 720803 3  6.578661
        300012 315005 3  6.578661
        300012 408583 4  7.120476
        300012 407674 3  6.578661
        300012 408582 4  7.120476
        300012 315006 3         .
        300012 720803 5  5.729524
        300012 315006 4         .
        300013 317604 4  5.165946
        300013 406032 5  6.362245
        300013 406047 4  5.165946
        300013 406032 4  5.165946
        300013 317604 5  6.362245
        300013 406032 3  7.121995
        300013 406047 5  6.362245
        300013 406047 3  7.121995
        300013 317604 3  7.121995
        300014 722781 5         .
        300014 722782 5  8.229511
        300014 315641 5  7.850154
        300014 408664 4  7.921302
        300014 722781 4         .
        300014 408615 5  8.229511
        300014 722782 4  7.921302
        300014 315604 4         .
        300014 722781 3         .
        300014 408664 3  7.744731
        300014 408615 3  7.744731
        300014 315605 3         .
        300014 408605 4  7.921302
        300014 315604 5         .
        300014 315641 3  7.744731
        300014 315605 4         .
        300014 315637 4  7.921302
        300014 408605 3  7.744731
        300014 315641 4  7.921302
        300014 315605 5         .
        300014 408605 5  7.850154
        300014 408664 5  7.850154
        300014 722782 3  7.744731
        300014 315637 3  7.744731
        300014 408615 4  7.921302
        300014 315604 3  7.744731
        300014 315637 5  7.850154
        300015 304188 3  7.834811
        300015 304185 3  7.834811
        300015 730216 5         .
        300015 405518 4   6.88641
        300015 730216 3  7.834811
        300015 304185 5  7.958376
        300015 304187 4         .
        300015 405518 5  7.958376
        300015 730216 4         .
        300015 304187 5         .
        300015 405518 3  7.834811
        300015 304185 4   6.88641
        300015 304187 3         .
        300015 304188 5  7.958376
        300015 304188 4   6.88641
        300016 630586 5  5.179518
        300016 409643 3  5.737711
        300016 409643 4  6.624718
        300016 409642 5  7.942819
        300016 316342 4  6.624718
        300016 409642 3  5.737711
        300016 316343 3  5.737711
        300016 316343 5  5.179518
        300016 630586 4  6.624718
        300016 316342 5  5.179518
        300016 409641 3  5.737711
        300016 316341 4  6.624718
        300016 316343 4  6.624718
        300016 316342 3  5.737711
        300016 409643 5  5.179518
        300016 316341 3  5.737711
        300016 409641 4  6.624718
        300016 409642 4   7.42242
        300016 630586 3  5.737711
        300016 316341 5  6.985971
        300016 409641 5  5.179518
        300017 306543 4  6.571434
        300017 403621 3   6.13646
        end
        label var pid "Person identifier" 
        label var pcy "log per capita household income"
        
        bysort pid (wave) : gen pattern = string(wave) if _n == 1 
        by pid : replace pattern = pattern[_n-1] + string(wave) if _n > 1 
        by pid : replace pattern = pattern[_N]
        
        tabdisp pid if !inlist(pattern, "34", "45", "345"), c(pattern)
        
        tabdisp pid if inlist(pattern, "34", "45", "345"), c(pattern)
        Code:
         
        . tabdisp pid if !inlist(pattern, "34", "45", "345"), c(pattern)
        
        ----------------------
        Person    |
        identifie |
        r         |    pattern
        ----------+-----------
           306543 |          4
           403621 |          3
        ----------------------
        
        . 
        . tabdisp pid if inlist(pattern, "34", "45", "345"), c(pattern)
        
        ----------------------
        Person    |
        identifie |
        r         |    pattern
        ----------+-----------
           301903 |        345
           302034 |        345
           303039 |        345
           304185 |        345
           304187 |        345
           304188 |        345
           304623 |        345
           304624 |        345
           305249 |        345
           305250 |        345
           305268 |        345
           305269 |        345
           305291 |        345
           305649 |        345
           309522 |        345
           311353 |        345
           315004 |        345
           315005 |        345
           315006 |        345
           315604 |        345
           315605 |        345
           315637 |        345
           315641 |        345
           316341 |        345
           316342 |        345
           316343 |        345
           317604 |        345
           319052 |        345
           319161 |        345
           319823 |        345
           319824 |        345
           319825 |        345
           321630 |        345
           321631 |        345
           381188 |        345
           402779 |        345
           405518 |        345
           406032 |        345
           406047 |        345
           407393 |        345
           407397 |        345
           407674 |        345
           408582 |        345
           408583 |        345
           408605 |        345
           408615 |        345
           408664 |        345
           409493 |        345
           409494 |        345
           409641 |        345
           409642 |        345
           409643 |        345
           410590 |        345
           470329 |        345
           582536 |        345
           583034 |        345
           620604 |        345
           620952 |        345
           630586 |        345
           720802 |        345
           720803 |        345
           720804 |        345
           720805 |        345
           722781 |        345
           722782 |        345
           730216 |        345
        ----------------------

        Comment

        Working...
        X