Statalist The Stata Listserver


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

st: how to assign new identifier numbers with duplicates


From   "Linda, X Zhu" <lx_zhu@hotmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: how to assign new identifier numbers with duplicates
Date   Tue, 27 Mar 2007 17:52:20 +0200

Dear Stata users,

I am using a firm-level panel data for performance analysis of firms. But I found that my dataset has duplicated identifiers (e.g. the same identity numbers for two firms in two different regions in a certain year). My dataset looks like as follows (a1 is a code for high-level region, a2 is the subregions, a3 is the firm identity number):

year a1 a2 a3
1995 450 57 206141
1995 450 54 206141
1996 450 57 206141
1996 450 54 206141
1997 450 57 206141
1997 450 54 206141
1995 470 41 223243
1995 470 43 223243
1995 470 44 223243
1996 470 41 223243
1996 470 44 223243
1997 470 41 223243
1998 470 41 223243
2000 470 41 223243


This moment, I donít want to consider the differences of subregions. So, I want to change the identity number such that I have uniquely identified observations by the identifier variable a3 and year. From the help, I found and did as follows (a3 is my identifier variable):

duplicates report a3 year

Duplicates in terms of a3 year

--------------------------------------
copies | observations surplus
----------+---------------------------
1 | 14906 0
2 | 2176 1088
3 | 87 58
--------------------------------------

. duplicates tag a3 year, gen(isdup)

Duplicates in terms of a3 year

. duplicates tag a3 year, gen(isdup)

Duplicates in terms of a3 year

. edit if isdup

This gives me a way to reassign an identity number for each duplicated firm. But since my dataset is big (I need to renumber 1088+58=1146 firms), I think it would be more convenient to use other commands, e.g. replace. So, I did the following:

. replace a3=1000000+a3 if isdup==1
(2176 real changes made)
. replace a3=2000000+a3 if isdup==2
(87 real changes made)

But then I changed all the duplicated numbers into another (still the same) number for two or three firms. Could somebody tell me how to change identity numbers in an easier way?

Thanks for your kind response.

Linda
Wageningen University NL

_________________________________________________________________
Live Search, for accurate results! http://www.live.nl

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