Announcement

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

  • Grouping and Panel Data

    I am carrying out a study using panel data I would like t group the countries into regions, which I have been able to do using the following command:
    generate region = 5
    replace region = 1 if inlist(country, "Burundi", "Kenya", "Uganda", "Rwanda", "Mauritius")
    replace region = 2 if inlist(country, "Burkino Faso", "Togo", "Mali", "Nigeria", "Mauritania", "Senegal")
    replace region = 3 if inlist(country, "Egypt", "Sudan", "Morocco", "Tunisia", "Algeria")
    replace region = 4 if inlist(country, "Eswatini", "Botswana", "Namibia", "Lesotho", "South Africa")
    replace region = 5 if inlist(country, "Cameroon", "DR Congo", "Gabon")

    Nevertheless, when I tabulated it using 'tab region', I realised that though the total value of the observations are correct, the values in each of the regions are not correct. How do I correct this?

    Please note that the panel is unbalanced.
    Thank you.

  • #2
    Please post an example showing what you mean when you state

    Nevertheless, when I tabulated it using 'tab region', I realised that though the total value of the observations are correct, the values in each of the regions are not correct.

    Comment


    • #3
      Obioma:
      welcome to this forum.
      As an aside to Andrew's helpful advice, what if you start it all over again typing:
      Code:
      generate region = .
      replace region = 1 if inlist(country, "Burundi", "Kenya", "Uganda", "Rwanda", "Mauritius")
      replace region = 2 if inlist(country, "Burkino Faso", "Togo", "Mali", "Nigeria", "Mauritania", "Senegal")
      replace region = 3 if inlist(country, "Egypt", "Sudan", "Morocco", "Tunisia", "Algeria")
      replace region = 4 if inlist(country, "Eswatini", "Botswana", "Namibia", "Lesotho", "South Africa")
      replace region = 5 if inlist(country, "Cameroon", "DR Congo", "Gabon")
      :
      Kind regards,
      Carlo
      (Stata 16.0 SE)

      Comment


      • #4
        Yes, I did not catch that Carlo Lazzaro. That would indeed result in a miscount of the last group.

        Comment

        Working...
        X