To visualize your data, you need to create a new ID for each individual regardless of how many records each person has. For example, the first person has three records, and we would like to assign a new ID 1 for the first person, and the second person would be 2.
Though it sounds difficult and tedious, it is not difficult to do so.
egen id = group(oldid)
Just one line and your problem will be solved.
Reference: http://www.stata.com/support/faqs/data/group.html
Comments
One response to “Stata: Create id by group”
Post a Comment | Post Comments (Atom)
How about creating a new id using your old id and three alternatives? So if I have 3 options (1,2,3), and three alternatives that ( R (6,4,2), A(10,4,2), and G(High,Med,Low)). I want to create newid 111111111.
November 15, 2013 at 3:01 AMThank You,
B
Post a Comment