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

st: Re: RE: how to obtain a unique identifier from strings


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: RE: how to obtain a unique identifier from strings
Date   Fri, 04 Nov 2005 10:13:40 -0500

Actually, that code would give you the count for each name, not assign unique identifiers. There are many ways to get what you want, but egen id=group(name) is probably the easiest.

Michael Blasnik
michael.blasnik@verizon.net

----- Original Message ----- From: "Kallimanis, Bellinda" <bkallimanis@fmhi.usf.edu>
To: <statalist@hsphsun2.harvard.edu>
Sent: Friday, November 04, 2005 9:58 AM
Subject: st: RE: how to obtain a unique identifier from strings



bysort name: gen id = _N

This should do the trick


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Teresio
Poggio
Sent: Friday, November 04, 2005 9:47 AM
To: statalist@hsphsun2.harvard.edu
Subject: st: how to obtain a unique identifier from strings

Dear statalisters,

this may be an elementary question but I could not find a solution in
Stata documentation and the list archives, so here I am...

I'm working (Stata 9/SE) with a quite large dataset (>300.000 records)
with observation on individuals. Each individual may be related to
more than one record. The structure is as following:


Teresio    0     1     0
Mario      1     2     0
Teresio    1     1    2
....

I'ld like to convert a string variable "Name" into a unique numerical
identifier and obtain something like this:

1            0     1     0
2            1     2     0
1            1     1    2
....

Is there any way to do this job in Stata?
I've tryed with the encode command, but Stata stopped because there
are more than 65000 unique values (by the way: I don't care about
labels ...).


Any help would be appreciated,

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