Announcement

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

  • Plotting a graph with several observations per year

    Hello everyone.

    I am currently working on a data set with trade values broken down into single transactions and have the task to make descriptive graphs.

    The problem I face is that there are several values per year. It is structured like this (with about 50,000 observations on 120 countries):

    Variables: country years trade_total
    Country1 2010 Value 1
    Country1 2010 Value 2
    Country1 2011 Value 3
    Country1 2011 Value 4
    Country2 2010 Value 5
    Country2 2010 Value 6
    Country2 2011 Value 7
    Country2 2011 Value 8

    So I wanted to do line graphs showing the total value of transactions per year and per country using a code like

    twoway line trade_total year, by(country)

    But these graphs turn out very bad, because there are several observations per year.

    I'm a beginner in stata, so excuse my missing expertise, I didn't find any posts regarding this exact problem when it comes to plotting.





  • #2
    Your trade_total variable itself should be summed, as in


    Code:
    egen double trade_sum = total(trade_total), by(country year) 
    egen tag = tag(country year)
    However, even a plot

    Code:
    line trade_sum year if tag, by(country)
    will suffer because of the number of countries, so at best this code will solve one problem and leave you with all the other problems.

    Comment

    Working...
    X