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]
Re: st: creating a new variable with different values for each record considering values in two different variables
From
Nick Cox <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: creating a new variable with different values for each record considering values in two different variables
Date
Tue, 18 Mar 2014 15:17:48 +0000
egen id2 = group(id class), label
is one way to do it.
Nick
[email protected]
On 18 March 2014 15:04, Raffaele Palladino <[email protected]> wrote:
> Dear statalist user, here it is a question for you:
> I have a dataset with an "id" that is referred to each person but it can be repeated in the dataset, than I have another variable "class", that stands for a classification, it can be repeated in the database as well. I would need to create a new id, unique for each record, that defines each record not only for the id by also for the class. Something like in the example below:
>
> id class id2
> 1 a 1
> 1 b 2
> 3 f 3
> 2 b 4
>
> There must be some combination of egen and by but I wasn't capable of finding it. Many thanks in advance!
>
>
>
> *
> * 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/
*
* 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/