Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: help creating a unique identifier


From   Phil Schumm <[email protected]>
To   [email protected]
Subject   Re: st: help creating a unique identifier
Date   Thu, 17 Mar 2005 11:17:28 -0600

At 1:42 PM -0300 3/17/05, Joao Pedro Wagner de Azevedo wrote:
I have a dataset with the variable id_dom (numeric) which s a unique
identifier of households and the variable age (see extract below). I would
like to create a couple of new variable and I would sincerely appreciate if
anyone on the list give me a hand.

First, I would like to create a sequential unique identifier such as
variable SeqID. Second, I would like to create a variable which would flag
all those households with at least on adult (age>=15).

egen SeqID = group(id_dom)
bys id_dom: egen agegt15 = max(15<=age)


The first command will generate consecutive integers, one for each value of id_dom (according to the sort order of id_dom). The second will create a 0/1 variable constant within id_dom, where a one indicates that there is at least one observation with age >= 15.


-- Phil
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/




© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index