Announcement

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

  • Expanding an observation to various rows

    Hi,

    I have a data set of a household survey with hhcode denoting the household code and migrant denoting a dummy variable 1 if the household has received remittance and 0 otherwise

    I want all the migrant values to be 1 for similar hhcode corresponding code.

    hhcode migrant
    1102100101 1
    1102100101 0
    1102100101 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100103 1
    1102100103 0
    1102100103 0
    1102100103 0
    1102100103 0
    1102100104 0
    1102100104 0

    I want the data to be this way:

    hhcode migrant
    1102100101 1
    1102100101 1
    1102100101 1
    1102100102 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100102 0
    1102100103 1
    1102100103 1
    1102100103 1
    1102100103 1
    1102100103 1
    1102100104 0
    1102100104 0


  • #2
    Code:
    bys hhcode (migrant): replace migrant = migrant[_N]

    Comment


    • #3
      Thank you so much! It worked!

      Comment

      Working...
      X