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!
Related Posts with Merge on organization number & month, collapse data to organization and month level
How to store p-value and CI in a new variable in prais-winsten regression?Hi! I'm new to Stata! I have a database model as shown below (hypothetical data). When running Prai…
Post-estimation tests or heteroskedasticity check to confirm normality of the residuals?Hi Stata users, I'd like to ask for your help. I read STATA manual pdf on post-estimation for mixed…
what is the base for -collapse- percent statistic with by()?The -collapse- command (https://www.stata.com/manuals/dcollapse.pdf) has a -percent- statistic that …
Correlating random effects to study interhospital variationHi All, Using data from ~2000 hospitals, I have identified patients who underwent 1 of 3 operations…
spatial weight matrixHello, As part of my research, I want to build a spatial weight matrix. I want a variable that shows…
Subscribe to:
Post Comments (Atom)
0 Response to Merge on organization number & month, collapse data to organization and month level
Post a Comment