Hi there,

I have a peculiar problem. We are working with panachage voting from Swiss elections. Our dataset has this kind of peculiar structure (given by how the statistical office provides them in excel):
Candidate name Party name List number Votes from List 1 Votes from List 2 ....
A B SP List 1 1 2390 1199
C D SP List 2 2 1282 2478
The idea is that we have an entry per candidate from every list (more than 3000 total). I want to calculate how many votes each candidate got from his list AND lists from the same party.

What I am thinking of is to rename the "Votes from list 1" variable to "SP List 1" (note that "SP List 1" applies to several indidivuals in the dataset). Is there a way to automatically do this?


The reason I'd like to autoamtically do this is that we wiill eventually have 20 regions with different list names and about 7 elections, so doing this by hand would likely be outside of the scope of our work. However, this can be ignored for the solution, since the data is in such a format that I can reasonably do a possible automation code for each region.

I should mention that this is for class work in political science. I hope my explanation of the problem is understandable

Thank you very much for your help!