I have unique IDs in rows where columns are the ID
s of their 'sent' friends. To get a count of 'received' friends, I need to get a count for how many times an ID appears across all columns and rows of the dataset. This is easy in R, but I'd like to stay with Stata for this project.
ID | F1_ID | F2_ID | F3_ID | ID_mentions |
---|---|---|---|---|
1 | 2 | 3 | 4 | 4 |
2 | 4 | 1 | 4 | |
3 | 1 | 2 | 3 | |
4 | 2 | 1 | 3 | 3 |
Toy data above. Here, there are four mentions of ID #1
, three mentions of ID #4
, etc.
I want to generate a variable containing the count of how many times each ID
value in the first column is mentioned in any column of the data set. This is illustrated in the ID_mentions
column.