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: RE: Duplicates order tagging
From
"Jesper Lindhardsen" <[email protected]>
To
<[email protected]>
Subject
st: RE: Duplicates order tagging
Date
Fri, 28 Oct 2011 08:34:07 +0200
Try
bysort letter: gen order = _n
HTH
Jesper
Jesper Lindhardsen
MD, PhD candidate
Department of Cardiovascular Research
Copenhagen University Hospital, Gentofte
Denmark
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Ben Hoen
Sent: 28 October 2011 06:28
To: [email protected]
Subject: st: Duplicates order tagging
Hello,
If I have a set that contains the following values:
letter
1. A
2. A
3. A
4. B
5. B
6. C
I can use .duplicates tag, g(freq) to generate a count of the
duplicates:
letter freq
1. A 3
2. A 3
3. A 3
4. B 2
5. B 2
6. C 1
But I would also like to generate an order variable (e.g., " order")
that
increases for each successive iteration of the variable. Such as:
letter freq order
1. A 3 1
2. A 3 2
3. A 3 3
4. B 2 1
5. B 2 2
6. C 1 1
Is there an easy way to do that?
Thanks,
Ben
Ben Hoen
Principal Research Associate
Lawrence Berkeley National Laboratory
Office: 845-758-1896
Cell: 718-812-7589
[email protected]
http://eetd.lbl.gov/ea/emp/staff/hoen.html
*
* 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/
*
* 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/