Dear all,
Let's suppose I have a variable displaying the amount of input in a given industry for each country: X_AUSTRALIA, ..., X_JAPAN, ..., X_USA, etc.
My goal is to create a new variable for each country which would be the sum of X excluding the country I am interested in. For instance, for Australia, I want the sum of X over all countries except Australia, and so on for each country.
Ideally, I would like to do that in a loop since I have a lot of countries. I have already created a global containing all the countries.
Anyone has an idea about how to produce theses variables within a loop ? That would be very appreciated. Thank you.
Related Posts with Sum of a variable over all observations except one (loop)
teffects - predict pscore, psI estimated the following model before estimating. I need to check the predicted propensity score mo…
elasticity- price, income etc. do i use a log-log model or employ mfx-eyex?Hi, I am very new to Stata so I apologise for the amateur-ness of my question. How do I calculate pr…
Probit regression coefficientsDear all, I have conducted a double-bounded contingent valuation study and analysed it in Stata with…
Assign a label of a variable to a different variable Code: gen x = 1 label var x "this is x" gen y = 2 label var y "this is x" // <- how to automat…
cumulative sum that restarts at 0, if observe "0" in the original column.Hi, I have a simple question. I would like to have a cumulate sum that restarts if observing 0 in th…
Subscribe to:
Post Comments (Atom)
0 Response to Sum of a variable over all observations except one (loop)
Post a Comment