Dear All, Suppose that I have this data set (the original question is here),
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input int(A B) str9 C float(ID1 ID2)
1 2010 "艾一" 2 1
1 2011 "张三" 1 2
1 2012 "张三" 1 2
2 2010 "李四" 3 3
2 2011 "李四" 3 3
3 2012 "车八" 6 4
3 2013 "王五" 5 5
3 2014 "李白" 4 6
end
The raw data have three variables, A, B, and C (names). If I use
Code:
egen ID1=group(A C)
I obtain ID1 variable. However, the desired outcome is ID2 (keep the order/names of C unchanged, and the group number is in an increasing pattern ). Any suggestions? Thanks.