Dear all,
Please take a look at the attached screenshot of a dummy dataset. How do I generate a variable Relatives, which tells me for every individual in a household, how many others in that household have the same colour as that individual?
For example, in household A, there are 2 red people, 2 blue people, and 2 pink people. Therefore individual A1 has 1 other relative who has the same colour as him - red. Similarly, individual A3 has 1 other relative who has the same colour as him - blue. And similarly, in household B, individual B4 is the only pink person, therefore the number of relatives who have the same colour as him is 0.
The actual data set has a lot more colours and a lot more households.
Thanks in advance!
Related Posts with Counting those in the same category as you, by group
Difference in Difference Analysis Using Panel and Time Series DataI am trying to conduct difference in difference analysis. I want to look at whether bank holding com…
qregplot A module for plotting quantile regression CoefficientsDear all, Thanks to Prof. Baum, a new command "qregplot" is available from SSC. This new command is…
Summarizing first row data within subgroups conditioned on IDHello! I want to accumulate values from the first occurrences or the first row given a specific rou…
Seemingly unrelated regression with panel data fixed effectsI have a panel data set with id=52 and time variable year, 2000 to 2018 (988 observations). I would …
Delete whole rowI have discovered that I have duplicates for a whole row (same person).. how do I delete the rows wi…
Subscribe to:
Post Comments (Atom)
0 Response to Counting those in the same category as you, by group
Post a Comment