Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Creating a unique identification number within a group


From   Tunga Kantarcı <[email protected]>
To   [email protected]
Subject   st: Creating a unique identification number within a group
Date   Wed, 7 Aug 2013 17:24:10 +0200

Hello,

I have three variables (a, b, c) which together uniquely identify a
certain characteristic (call it u). I create a unique identification
number from these three variables using the code

egen u = group(a b c) and this gives:

a b c u
1 2 3 1
1 2 4 2
1 2 4 2
9 2 3 3
9 2 4 4
9 2 4 4

However what I would like to have is that for each "a", "u" starts
from 1 so that I get:

a b c u
1 2 3 1
1 2 4 2
1 2 4 2
9 2 3 1
9 2 4 2
9 2 4 2

Of course in this case u is not a unique identifier in the whole
dataset, but it is so within each a. Could I achieve this?
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index