Dear All,

I have a dataset structured as follows. It is actually an Input Output (IO) matrix. So you have flows from country-sectors on the observation side and each variable represent the sector from which the inputs are actually taken in that given sector. So basically there are a lot of countries named with the three letter names (e.g. AUS for Australia and so on) and for each one 56 sectors at the NACE 2 level. I have already collapsed observations to sum them up at the NACE 1 and as you can see i have 10 sectors for each country. I want to do the same with variables. So it should be something like generating a new variable called "name_of_the_country"_A which is the sum of "name_of_the_country"1,2,3; a variable called "name_of_the_country"_B which is the sum of "name_of_the_country"4; a variable called "name_of_the_country"_C which is the sum of "name_of_the_country"5 to 19; and so on, so that i can have country and sectors at the NACE 1 level also on the variable side.

What is the best way to achieve this. Thank you all for the help.

**dataset attached Array