Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using bysort

    Dear All,

    I'm trying to run something like this:

    Code:
    bysort country: egen var1 = total(x_gdp) if region=="region1" & year==year1
    Such that I don't have to use the "if" option. Looking for a code to generate a variable that will give me: (i) the total export from country A to all the countries in region1 at year1.

    I have regions 1 to 5 and countries A to Z.

    Please note: the set of countries under the regions are different from the set of countries in which am taking sum.

    Thank you,
    Dapel

  • #2
    The fact that the countries under the regions are not the countries over which you are summing should make no difference.

    Try
    Code:
    bysort country region year: egen var1 = total(x_gdp)
    and look at the results and see if it correctly calculated what you need.
    Last edited by William Lisowski; 15 Apr 2020, 12:51.

    Comment

    Working...
    X