Announcement

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

  • Create graphs

    Dear all,

    I have a dataset that contains the following string variables: "country" and "countrydestination". The first variable includes all African countries as individual country observations in the year 2000. Each country then has many - kind of - results with "countrydestination" (the country where African refugees emigrate to --> there are many listed for each country of origin).

    I would like to create a graph (preferably a pie chart or a bar graph) that shows which countries Africans are fleeing to the most.

    My thought (before starting with the graph) is: I would like to summarize all the African countries so that it is only "Africa" --> not individual countries, but only the entire continent. And then I would like to have the top 5 or top 10 countries that are destinations.

    Unfortunately, I don't have a solution for any of these three problems (A: Summarize countries to Africa, B: Show only the top 10 destinations and C: create the graph).


    Every help is very much appreciated!
    Thank you to everyone in advance!

    Kind regards,
    Marah

  • #2
    You need to create an indicator for Africa then contract this variable and country of destination.

    Code:
    help contract
    Then sort in descending order and keep the top 5 observations before graphing.

    Code:
    gsort -_freq
    keep in 1/5
    If the observations contain counts to begin with, you may need

    Code:
    collapse (sum)
    in place of contract. In any case, you need to present a data example using dataex if you need better advice. See FAQ Advice #12 for details.

    Comment

    Working...
    X