Announcement

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

  • Calculate means for groups of countries

    Hello,

    I have a dataset with numerous countries for several years. One of this variables is the level of corruption in a country. Furthermore I have a variable that says if they belong or not to the OECD.

    I have the following doubt:
    I would like to know how can I generate a variable that calculates the mean of corruption only for the countries that are included in the OECD?

    The objective is to create a graph where I can see the evolution of this variable only for OECD countries.

    Thank you in advance.

  • #2
    Try:
    Code:
    egen mean_corruption = mean( corruption), by( OECD_code)
    where OECD_code is a dummy variable that equals 1 if a country is an OECD country.

    Comment


    • #3
      Sorry, you want a mean of the corruption for each country in the OECD in that case the code will be:
      Code:
       
       egen mean_corruption = mean( corruption) if OECD==1, by(country)

      Comment

      Working...
      X