Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Transforming Unique IDs


From   Maarten Buis <[email protected]>
To   [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index