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: question about ids in a group
From
Pat R <[email protected]>
To
[email protected]
Subject
st: question about ids in a group
Date
Sat, 19 Mar 2011 21:16:27 -0400
Hi all,
I have a panel dataset from which I'm trying to make a smaller dataset
with new identifiers. My (new) dataset is organised this way right
now:
QID | Year | PersonID
1 | 2009 | 3
1 | 2009 | 4
2 | 2009 | 9
2 | 2009 | 10
2 | 2010 | 9
2 | 2010 | 10
2 | 2009 | 11
I want to create new identifiers for each person (consistent across
years), starting from 1, within each QID. I tried using the -egen
group- function, but since I cannot combine that with -by-, it creates
unique values which ignore the QID. I tried using -egen rank-, but
that of course skips a rank if two IDs are the same. I'm sure there's
a terribly easy way to do this, but I just can't see it. Can anyone
help? (It's my first time asking a question, so I apologize if I've
left out important information)
Cheers,
Pat
*
* 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/