Hi everyone,

I have a datalist where I want to count the number of men working in an organization in a specific month. For every man there is a draw, since there are different roles per year.

In the dataset I have information about the specific organization; Organization number, about the employee; Employee number, about the gender; Man=1 or Man=0 and about the month this was measured.
I want to calculate the total number of men working in a specific organization in a specific month.

I already tried: egen nman = total(man==1), by (organizationnr)

But then the number of nman is the same in every month; since Stata calculates the total of man=1, also in the months where there is no man working in the organization.
The second problem here is that Stata sees no difference in the employee number; so in this specific example; stata gives 6 for nman for all the months, but this should be 1 in some months, since there is only 1 man working in the organization, the only thing is that there is data for this man for 6 months available.

If I try to use egen nman = total(man==1), by (organizationnr & month) I get an error. I think it is not possible to use two "by" commands?

Can anyone help me further with this? How do I collapse the data based to organization and month level? Would it help if I create a dummy at month level?

I thank you in anticipation!