Hi, I posted yesterday, and got some helpful advice, though I would like some feedback on how to tackle this issue when the data is in long form, as the states as variables makes more sense for my data than the content for the purpose of this analysis.

Here's my post from yesteday: https://www.statalist.org/forums/for...s-of-variables

Essentially, I am dealing with states as individual variables and their coverage of content as individual observations. The data for each state represents the amount of which said topic is covered in materials by the state; comparing two states at the same observation would show how much they have in common on that topic. Eventually, I want to sum how much they have in common as a score of how aligned the materials of the two states are.

Here's an example of my data


Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(US1 US7 US14 US24 US33)
                0 0 0                 0 0
                0 0 0                 0 0
.0095238095238095 0 0                 0 0
                0 0 0 .0076923076923077 0
                0 0 0                 0 0
end
So, the main thing I want the loop to accomplish is to generate all of the permutations (or combinations if that's easier, but permutations are fine considering they could be found and dropped in post) possible of US*, with each as its own variable name. For example, the first loop would look like
egen US1US1 = rowmin (US1 US1)
egen US1US2 = rowmin (US1 US2)

until egen US1US39 (the last state where data is available)

And then I want the cycle to repeat.

Last, though this part of the loop would be simpler, but just in case you're wondering, I would sum the rowmins of an individual column to create each states' total alignment and then drop the rowmin variable.

Thanks in advance and stay safe wherever you are