[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: Re: help creating a unique identifier
As flagged by Michael, there are several FAQs
relevant to this kind of manipulation.
How do I create individual identifiers numbered from 1 upwards?
How do I create a variable recording whether any members
of a group (or all members of a group) possess some
> A similar question was recently asked and FAQ certainly
> addresses the unique
> identifier, but here are some answers:
> egen SeqId=group(id_dom)
> sort id_dom age
> gen SeqId=sum(id_dom!=id_dom[_n-1])
> for your second question, if there are no missing values on
> age, then this
> bysort id_dom (age): gen byte hasover15=age[_N]>=15
> otherwise, the easiest approach may be:
> egen maxage=max(age),by(id_dom)
> gen byte hasover15=maxage>15 if maxage<.
Joao Pedro Wagner de Azevedo
> > 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).
> > Initially I would like to avoid having to use collapse and
> merge (given
> > the
> > size of my dataset), and I have been trying to use command
> such as bysort,
> > _n and _N.
* For searches and help try: