egen idcode=group( 变量)
group(varlist) [, missing label lname(name) truncate(num)]
may not be combined with by. It creates one variable taking on values 1, 2, ...
for the groups formed by varlist. varlist may contain numeric variables, string
variables, or a combination of the two. The order of the groups is that of the
sort order of varlist. missing indicates that missing values in varlist
(either . or "") are to be treated like any other value when assigning groups,
instead of as missing values being assigned to the group missing. The label
option returns integers from 1 up according to the distinct groups of varlist in
sorted order. The integers are labeled with the values of varlist or the value
labels, if they exist. lname() specifies the name to be given to the value label
created to hold the labels; lname() implies label. The truncate() option
truncates the values contributed to the label from each variable in varlist to
the length specified by the integer argument num. The truncate option cannot be
used without specifying the label option. The truncate option does not change
the groups that are formed; it changes only their labels.