Stata FAQ How can I create dyad IDs?
Data management with dyadic data can be difficult. Before analyzing dyadic data, one may wish to know how many unique dyads appear in a dataset and create an ID variable at this dyad level. In this page, we will demonstrate how to create unique dyad IDs in Stata. First, suppose individuals within teams rated each other on a skill. This data is collected in a dataset with a row for each rating given and the team, rater, and ratee are indicated. The same individuals act as both raters and ratees and each individual in the dataset has a unique ID. The variable y is the rating assigned to ratee by rater. To create dyad IDs, we will first use integer values such that the maximum of our ID variable is the number of unique dyads in the dataset. This approach will work regardless of the format of the rater/ratee IDs. We will then show a quicker method for getting unique dyad IDs that requires that the rater/ratee IDs be numeric. use http://www.ats.ucla.edu/stat/stata/faq/dyads, clear list in 1