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
Create value-weighted decile portfoliosI want to build Dezil portfolios based on the last observed values of the respective calendar year f…
Problem with MergingHi, I am trying to merge two datasets which look as follows: Master Data: Year State Constituen…
From yearly to quarterly dataHello to all! I am new to this Forum, please apologies if I am not using it right. I have a question…
Help with strtrimHello, I have noticed that I have some likert-scale variables where some of the values have trailin…
Monte carlo simulation to test RE modelHi folks, I run a random effect model and would like to make a robustness test with monte carlo. I …
Subscribe to:
Post Comments (Atom)
0 Response to Counting those in the same category as you, by group
Post a Comment