Announcement

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

  • How to count number of countries when you have individual-level data of many countries

    Hi,

    I need to fill in my descriptive statistic analysis sample, and thus I need to count the number of countries in the data set. However, I don't know a clever way to do this? I'm using GEM data, so I have a lot of observations (around 144.000) in a lot of countries. The variable name is country, but it's not a variable in my regression. What command should I use? I couldn't find it on the internet...

    Thanks in advance!

    Kind regards,
    Josephine

  • #2
    After your regression you type:
    Code:
    levelsof country if e(sample)
    di `: word count `r(levels)''
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Thankyou!

      Comment


      • #4
        Another useful device is -egen, tag()- function which tags one observation per group, and from there on you can use the -if tag- qualifier at the end to compute summary statistics involving only one observation per country.

        Yet another way is to just tabulate country.

        Comment


        • #5
          Originally posted by Joro Kolev View Post
          Another useful device is -egen, tag()- function which tags one observation per group, and from there on you can use the -if tag- qualifier at the end to compute summary statistics involving only one observation per country.

          Yet another way is to just tabulate country.
          Thanks! Totally forgot about the tabulate command as well

          Comment

          Working...
          X