Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Transforming Unique IDs


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Transforming Unique IDs
Date   Mon, 23 May 2011 12:35:15 +0200

On Mon, May 23, 2011 at 12:17 PM, Dennis Kramer wrote:
> I am working with a large panel data set and I need to transform the
> current unique IDs into a new set of unique IDs while maintaining the
> panel nature of the data.
> does anyone have a algorithm to produce a new set of unique IDs while
> maintaining the panel function?

I don't think you need to do anything special, just -generate- your new IDs.

A general warning when working with IDs is that if the numbers are
large than it is probably safest to work with strings rather than
numbers.

*----------- begin example -------------------
// create example data
drop _all
set obs 3
gen id = _n
expand 3
bys id: gen year = _n
list

// create two new ids
gen newid1 = 10 + id
gen str newid2 = "1" + string(id)

list
desc

// newid2 is a string, this is much
// safer when working with id's that
// are large numbers
*----------------- end example ----------------
(For more on examples I sent to the Statalist see:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

--------------------------
Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen
Germany


http://www.maartenbuis.nl
--------------------------
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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   |   Site index