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
can i use mi chained logistic and how to weight respondentsi have combined survey data sets from 32 countries and have about 90k respondents, the number of res…
Aidsills with market fixed effectsDear Statalisters, I am using Stata ver 14, and the built in command aidsills written by Lecocq and…
Lagged variables of daily dataHi, I have a dataset of stock returns, with daily returns (panel). I have successfully created runn…
Direction of bias?Dear all, I am trying to determine directions of biased (upward or downward) estimates in my study …
To both experienced Stata programmers, and Stata users: How do you prefer to have the command, as a post estimation or as a prefix?Good afternoon, I have written a command to estimate robust variance post Seemingly Unrelated Regre…
Subscribe to:
Post Comments (Atom)
0 Response to Counting those in the same category as you, by group
Post a Comment