--- Jia Xiangping wrote:
> For a datafile like :
> id var1
> 1 1
> 1 2
> 1 3
> 2 1
> 2 2
> 2 1
>
> I expect to check whether the value of "var1" within
> one group of "id" is unique -- i.e. in group 2, the
> values are not unique.
_N in combination with -bys- gives the total number of
observations withing each group defined by the variables
in -bys-. So if var1 uniquely identifies individuals
within id, than _N within -bys id var1- should always be
1, and any duplicates will be identified with _N larger
than 1. So you can do something like this:
bys id var1: gen byte duplicates = _N > 1
list id var1 if duplicates == 1
Hope this helps,
Maarten
-----------------------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany
http://home.fsw.vu.nl/m.buis/
-----------------------------------------
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/