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
Goodness-of-fit and mediation analysis in GSEMHi, all I am hoping for some insights into an appropriate independent goodness-of-fit test for GSEM…
How to adjust weights when combining multiple survey data?Dear all, I am currently trying to estimate a model using WLS using a survey data for multiple peri…
Regression output - Bug?Hi everyone, I am trying to run some old code (version 14.2) using a new Stata version (15.1) on a …
Faults and Hiccups in the programThe week code is incorrect, and the week starts on Wednesday instead of Monday, which has persisted …
Adding new rows to the dataset to create conversation turnsHello! I am working on a text mining project that requires input text to be in a specific format. T…
Subscribe to:
Post Comments (Atom)
0 Response to Counting those in the same category as you, by group
Post a Comment