Announcement

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

  • How to count repeated data separately

    Hello,

    I have the following data in agriculture. I would like to know how many types of crops and how may types of seeds that the household plant in order to see the diversification.

    for example, household1 planted 12 different crops and 2 different seeds types

    Bu if I use the commands

    bys hhid pid: egen crops=count(cid)
    bys hhid pid: egen seeds=count(c2)

    they will count repeated value and make the crops types =18 and seed types =14

    are there commands/ways that I can count repeated data separately?

    thank you!
    hhid pid lid crop_id seed_type
    1 1 1 maize local
    1 1 1 maize local
    1 1 1 maize .
    1 1 1 maize .
    1 1 1 beans local
    1 1 1 beans local
    1 1 2 coffee improved
    1 1 2 groundn local
    1 1 3 sweet potato local
    1 1 4 tea improved
    1 1 5 mangoes local
    1 1 5 napier local
    1 1 5 avocado local
    1 1 7 bananas local
    1 1 8 cowpeas .
    1 1 8 cowpeas local
    1 1 9 indigen .
    1 1 9 indigen local




    Last edited by Trang Thu Vu; 10 Aug 2018, 02:38.

  • #2
    See e.g. the thread earlier this week https://www.statalist.org/forums/for...encies-by-year and its references.

    Comment


    • #3
      Thanks Nick Cox! I checked earlier thread and it works now.

      Comment

      Working...
      X