Dear Statalist.

I have a question that I think expands on Nick Cox's FAQ: https://www.stata.com/support/faqs/d...-to-all-pairs/

In short, I have a dataset with observations of objects belonging in either group 1 or group 2.
I would like to expand my dataset and identify all possible pairs of objects that cut across group 1 and group 2.

So, if we have a toy dataset:
group id
1 1
1 2
2 3
2 4

I would like to identify all possible pairs of objects cutting across groups like this:
group id id dyadid
1 1 3 1
1 1 4 2
1 2 3 3
1 2 4 4
2 3 1 1
2 3 2 3
2 4 1 2
2 4 2 4
This may not be the best way to describe/visualize my problem, but any and all inputs or suggestions are very welcome.

Thanks!

Best,
Erik