I am trying to create dyads in my Stata data set for multiple variables, at the same time. Here is what I have:
Year id Freedom
2005 1 6.8
2006 1 7.0
.
.
2016 1 5.5
2005 2 3.8
2006 2 4.2
.
.
2016 2 5.4
I would like to turn it into this
Year id_1 id_2 Freedom_1 Freedom_2
2005 1 2 6.8 3.8
2006 1 2 7.0 4.2
.
.
2016 2 1 5.4 5.5
where id is the number of US states and goes from 1 to 50

Comment