Announcement

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

  • Fil panel waves with information of the first panel wave

    Hey all,
    I have the following problem with my panel data preparation: I have a variable which is only enquired in wave 1 but i want to fil all the other waves (2-7) also with this information.Who can i do this in STATA? How do i tell stata to take the information of the ID xy of wave 1 and use this for all other waves of this ID?

    Thanks for your support!

  • #2
    Anja:
    welcome to the list.
    Something along the following lines may be what you're looking for:
    Code:
    sort id (year)
    foreach var of varlist var2-var7 {
     replace `var'=var1 if `var'==.
     }
    However, set aside the case that the variable you're referring to is a time-invariant one (eg: place of birth) the approach you're intended to follow (last observed carried forward - LOCF) may seriously bias your analysis, as you assume that no variation across time occurs (LOCF often produces a time bias).
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3

      Code:
      bysort id (wave) : replace whatever = whatever[1] if missing(whatever)

      Comment


      • #4
        Dear Carlo,
        thank you so much for the answer.
        If I enter the code as follows:

        sort id (wave)
        foreach wave }
        replace wave = 1 if wave == 2
        replace wave = 1 if wave == 3
        replace wave = 1 if wave == 4
        replace wave = 1 if wave == 5
        replace wave = 1 if wave == 6
        replace wave = 1 if wave == 7
        }

        i get the error "invalid syntax", am i wrong?

        Thanks.

        Comment


        • #5
          Anja:
          the code you typed is illegal.
          Nick gave a more efficient approach, that I suggest you to follow.
          Kind regards,
          Carlo
          (Stata 18.0 SE)

          Comment


          • #6
            Note that apart from syntax errors, the approach in #4 is not at all what want. You don't want to replace the values of the wave identifier so that they all end as 1! You want to copy values of another variable from one observation to others.

            Comment

            Working...
            X