Hi, I'm looking for some help with a dataset that I need to create. I have two complex variables that I need to create from existing data. I have provided an example in the data below. The data describes political parties in a parliament (parties, a, b, c, and d), the share of seats each party has and the ideological position of each.
I have then taken these parties and found every possible combination of them, these are also listed below. The two variables that I need to create are the total seats that each combination would have together and the ideological range of the government which is the absolute distance between the two most distant parties in every combination. So in the example below you can see a combination of parties 'a, b, c'. The total seats for this combination is 70 if we add together the relevant values from the second column. The ideological range of the government is 9 because the lowest value in this combination is 'a' which is 11 and the lowest is 'b' which is 2.
What I would like to do is create a macro to automate this process since there are instances where there are over 2,000 combinations and coding this by hand is exhausting. Can anybody help with this? Is what I am trying to achieve even possible?
Thanks for any help you can give me.
Party Seats Ideological position a 40 11 b 20 2 c 10 7 d 5 4 Combination of parties Total seats Ideological range a 40 0 b 20 0 c 10 0 d 5 0 a b 60 9 a c 50 4 a d 45 7 b c 30 5 b d 25 2 c d 15 3 a b c 70 9 a b d 65 9 a c d 55 7 b c d 35 5 a b c d 75 9
Bookmarks