Announcement

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

  • Identify the Transferred Students across Districts in the Dataset in Stata

    I have a dataset as follows and I want to find the transferred students across districts in Stata.
    id-student id
    did-district id
    sid-school id

    clear
    input int did long sid float (id age count male)
    1 11 111 42 20 1
    1 11 111 30 20 1
    1 21 101 42 10 1
    1 11 111 34 10 1
    1 11 111 30 10 1
    1 11 111 33 10 1
    2 12 112 39 20 0
    2 12 112 40 20 0
    2 12 112 43 20 0
    2 12 112 33 20 0
    3 13 113 40 10 1
    3 13 113 41 20 1
    3 13 113 38 20 1
    4 14 114 32 10 0
    4 14 114 35 10 0
    4 14 114 32 20 0
    4 24 104 37 10 0
    5 15 115 31 10 0
    5 15 115 29 10 0
    5 25 105 36 10 0
    5 15 115 37 20 0
    end
    ren did stid
    ren sid sid
    ren id did

    Thanks for your Stata code!
    Last edited by smith Jason; 06 Jun 2022, 11:00.

  • #2
    stid-student id
    sid-school id
    did-district id
    I am sorry that I forgot to update the meaning of the variables above.

    Comment


    • #3
      I assume that transferred "across districts" means that the student was in one district at one time and a different district at some other time--change of school in the same district doesn't count.

      Code:
      by stid (did sid), sort: gen byte transferred_across_districts = did[1] != did[_N]

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        I assume that transferred "across districts" means that the student was in one district at one time and a different district at some other time--change of school in the same district doesn't count.

        Code:
        by stid (did sid), sort: gen byte transferred_across_districts = did[1] != did[_N]
        In fact, what I mean "transferred students" refers to the students who transferred from one district to another district and he/she can transfer back or not.

        Comment


        • #5
          In fact, what I mean "transferred students" refers to the students who transferred from one district to another district and he/she can transfer back or not.
          That is what you will get from the code in #3.

          Comment


          • #6
            Thank you, Professor!

            Comment

            Working...
            X