Hi All,

I am struggling to combine my long panel data to pairs and wonder if anyone can give me a hint.

Suppose I have a long panel dataset

Time Country Variable
t1 a a1
t2 a a2
t3 a a3
t1 b b1
t2 b b2
t3 b b3
t1 c c1
t2 c c2
t3 c c3

I would like to convert this dataset to following format

Time Country Pair Variable
t1 ab a1-b1
t2 ab a2-b2
t3 ab a3-b3
t1 ac a1-c1
t2 ac a2-c2
t3 ac a3-c3
.....
.....
t1 cb c1-b1
t2 cb c2-b2
t3 cb c3-b3

I thought about first converting the long format to wide format but I have 100+ variables, and 50+ countries, so the wide format will have a lot of variables.

Any hint or suggestions are extremely appreciated!!

Thanks!