Hello
I have a household data with a01 as the household id. Plotid represents the number of farming plot that household owns. h2_01 denotes the irrigation methods (labels below). I need to find out as to how many households are using rainfed as irrigation source (h2_01 = 1). One household can have multiple plots and can rely on rains for all those plots. I want to count the multiple plot observations as just "one" so as to get the number of farmers relying on rain.
I tried using contract and bysort command but that gives me the count for all plots of a household. Eg, if a01 = 4 has two different plotids (2 & 4) and it depends on rains (h2_01 =1 ) for both, I just want to count h2_01 for a01 = 4 only once. Please help.



Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int a01 float plotid byte h2_01
 1   2 1
 1   3 3
 1   3 3
 3   2 2
 3   3 2
 3   5 1
 4   2 1
 4   4 1
 4   5 2
 4   7 2
 5   2 3
 5   2 3
 5   3 1
 6   2 3
 7   2 1
 9   2 3
10   3 6
10   7 3
end
label values h2_01 h2_01
label def h2_01 1 "rainfed", modify
label def h2_01 2 "river", modify
label def h2_01 3 "canal", modify
label def h2_01 4 "pond", modify
label def h2_01 6 "canal irrigation", modify
label def h2_01 7 "groundwater", modify