How to see the Male , Female counts of a household in STATA
Suppose We did a survey of some household. Each Household has unique number. Now I wan to see how many males and females are in the household.For example, we have 3 families. So unique ID is 1 ,2 and 3. And ID 1 is same for all the respondents of the first family.
This is an example dataset. Here, In Gender
1 is Male. 2 is Female.
Now we want to know How many males and females are in each family. We can create new variable Male and Female.We can do this easily by the following code:
bysort ID: egen Male = count(ID) if Gender==1
bysort ID: egen Female = count(ID) if Gender==2
After running this our dataset will looks like
We can see that in first family there are 2 males and 2 females. In second family there are 3 males and 2 females. And in third family there are 3 females, no males.
We can see different things by filter the data such as:
ed ID Male if ID==1
We can see that there are 2 males in household with ID =1.