Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: creating an unique household identification number


From   "Simo Hansen" <simohansen@gmail.com>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: creating an unique household identification number
Date   Fri, 1 Sep 2006 21:48:13 +0300

Thanks Nick for your contribution. Indeed, I have a big data set-3.5 million
observations.
When you suggested using label with egen group (), do you mean to use this
command in the following form?
egen double newhhid=(batch_nu hhid_nu).
Thank you very much.
Simo

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nick Cox
Sent: Friday, September 01, 2006 9:22 PM
To: statalist@hsphsun2.harvard.edu
Subject: RE: st: creating an unique household identification number

In addition, -egen, concat()- works either way, 
and even with a combination of numeric and string 
inputs. The result is always string. 

Incidentally, with -egen, group()- you would
usually like to add the -label- option. However, 
Simo's dataset might be really big, in which 
case -egen, concat()- might offer the better choice. 

Nick 
n.j.cox@durham.ac.uk 

Friedrich Huebler
 
> If both variables are numeric you can do this:
> 
> . gen long id1 =  Batch_nu*10 + hhid_nu
> 
> If both variables are strings you can do this:
> 
> . gen id2 = Batch_nu + hhid_nu
> 
> This command works with strings and numeric variables:
> 
> . egen id3 = group(Batch_nu hhid_nu)

Simo Hansen 

> > I have a household level data that includes a batch number and
> > within each
> > batch number household id numbers. It looks like in the following
> > form:
> > 
> > Batch_nu          hhid_nu
> > 10100025          1                 
> > 10100025          2        
> > 10100025          3      
> > 10100031          1
> > 10100031          2
> > 10100031          3
> > 10100037          1
> > 10100037          2
> > 10100037          3
> >  My question is that how I can create an unique identification
> > number for
> > each household using batch_nu and hhid_nu.

*
*   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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index