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!
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 |
Comment