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!
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!

Comment