Announcement

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

  • Panel data and adding the occurrence of a dummy variable

    Hello all

    I am looking into how the number of times a person migrates affects their change in happiness levels.

    My question is that I have a dummy variable that shows when a person migrates ( 1 if they move in that year) but I don’t know how to have a variable that adds onto previous occurrences of this dummy variable showing 1. For example, when the person has already migrated once, there will be a variable to show that this is the second time of moving and so on for multiple migrations.

    I am using 15.

    Thanks in advance

  • #2
    So if your variable that shows when a person migrates is called migrates_now, and you have a person ID variable called id and a date variable called date, you can get what you want with:

    Code:
    by id (date), sort: gen number_of_migrations = sum(migrates_now)

    Comment


    • #3
      Thank you for this.

      Comment

      Working...
      X