My data is uniquely identified at the incident-student level, and I want to create a variable called "degree" that counts the number of students that one student has been in incidents with. For example, student X with studentid 325342 has been in incidents with 6 other students. I'm stuck figuring out how to not double count students that X has been in multiple incidents with (for example 325342 and 457875 were in 2 incidents together, but I only want 457875 counted once for student 325342). What I've unsuccessfully attempted:
Merge in the same data set, then reshape long (so there will be one studentid with many columns of studentid2). This only merged in one matched studentid per student even if there were multiple students per one incident... so I'm not sure what went wrong there
Code:
rename studentid studentid1 m:m merge incident using samedataset.dta
Code:
clear input incident studentid 1 325342 1 457875 1 367875 2 325342 2 342634 2 765486 3 354676 3 346745 3 547767 3 454748 4 578659 5 325342 5 457875 5 854755 5 354657 6 885675 end
Comment