Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 72784

creating an indicator for matching observations

$
0
0
Hello,

My data includes an ID variable for an individual, and a variable for the ID of the person's siblings: sibling2, ..., sibling5 within the household. I also have a variable bullied = 0 if the individual was never bullied, 1 if the person was ever bullied in one time period, and 2 if the person was bullied in more than one time period. What I'd like to do is to create a variable, sibbullied = 1 if the individual (ID) has one or more siblings who has a bullied value of 1 or 2; 0 otherwise. I'd also like to create a value totsibbullied = total amount of siblings who had bullied values of 1 or 2; 0 otherwise. For example:
ID sibling2 sibling3 sibling4 sibling5 bullied sibbullied totsibbullied
1 2 4 . . 1 1 1
2 1 4 . . 0 1 2
3 . . . . 1 . .
4 1 2 . . 2 1 1

Viewing all articles
Browse latest Browse all 72784

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>