Currently I have a dataset that appears as follows:
mnbr firm contribution
1591 2 1
9246 6 1
812 6 1
674 6 1
And so on. The idea is that mnbr is the member number of employees who work at firm # whatever. If contribution is 1 (and I have dropped all the 0s for this purpose) said employee has contributed to a certain fund.
I additionally used codebook to determine the number of unique firms that exist. The goal is to determine the average number of contributions per firm i.e. there was 1 contribution for firm 2, 3 contributions for firm 6 and so on. The problem I arrive at is accessing that the unique values number from codebook.
I read some documentation online for
inspect *varlist*
display r(N_unique)
which suggests to me that using r(N_unique) would store that value, yet unfortunately this method did not work for me. So that is part 1.
Part 2 is I'd also like to create a variable that shows the contributions in each firm i.e.
mnbr firm contribution average
1591 2 1 1
9246 6 . 2/3
812 6 1 2/3
674 6 1 2/3
to show that for firm 6, 2 out of the 3 employees contributed to this fund.
Thanks in advance for the help.
r(N_unique)
will be that of the last variable in the variable list. Tryinspect firm
(only one variable; the one you are interested, I believe). – Roberto Ferrerinspect firm
I get the desired output that produces a histogram and a table with the number of positive, zero, and negative entries among others. However when I try to implementdisplay r(N_unique)
the output is only.
and stata does not appear to be working on it any further. Hope that makes sense, it just outputs nothing for me, which is why I said it did not work for me, though I certainly should have clarified). – thyde