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
Related Posts with For-each loop to sum across groups of observation
Difficulty aggregating variables to the unit of analysis without losing or altering dataHello, I'm a first year grad student that is fairly new to Stata. I'm working on a project in which…
create a new var extracting part of string with different lengthHi, How can I create a new var(var2) extracting part of string from var1 with different length? The…
bysort gen n = _n with if condition 1/2/3/4 is trueHello everybody, I have a hospital list (ik) doing several surgeries (haupt_op). Now I want create a…
calculating unique occurrence of variableHello everyone, I have got a panel data set consisting of 12 waves. Every individual has got a uniq…
Variability over time of positive and negative valuesHello, I'm interested in calculating the variability over time of a variable that can takes either …
Subscribe to:
Post Comments (Atom)
0 Response to For-each loop to sum across groups of observation
Post a Comment