Statalist The Stata Listserver


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

st: Question about duplicates and tag command


From   "Mosca, Ilaria" <[email protected]>
To   <[email protected]>
Subject   st: Question about duplicates and tag command
Date   Mon, 27 Feb 2006 10:48:41 +0100

Dear Statalisters,

I have been working with a database in which I had to identify
duplicates of institutions and afterwards count the number of
institutions per year. I therefore wrote the following commands:

. sort code
. quietly by code: gen dup=cond(_N==1,0,_n)
. drop if dup>1
. gen id04==1 if year==2004
. count if id04==1

My problem is that EVERY TIME that I was running these commands, I
obtained different results! Once the count command was 749, once 753,
and so on. And this without any apparent reason.

In order to cope with this problem I therefore used the command tag, and
namely:
. sort code
. egen tag=tag(code)
. count if tag==1

I runned these commands several times and the results shown are always
the same. 

My question to you is thus the following: why does the command for
duplicates seem not to work in this case? I frequently have to identify
duplicates in my databases, and I use these commands pretty often. But
getting different results every time, cast doubts on its effectiveness.

Thank you in advance for your help.

Ilaria 

Met inachtneming van eventuele beperkende bepalingen in deze e-mail, mag u deze informatie gebruiken voor het doel waarvoor u die ontvangt. Aan deze gegevens kunnen geen rechten worden ontleend. CTG/ZAio aanvaardt geen aansprakelijkheid voor de juistheid en volledigheid van deze gegevens. Enige schade, ontstaan door de ontvangst of het gebruik van dit e-mailbericht of de informatie daarin, komt voor uw eigen verantwoordelijkheid. Als u een officiele beslissing (besluit, beslissing op bezwaar) van het CTG/ZAio wilt waaraan rechtsgevolgen verbonden zijn is een e-mailbericht onvoldoende. U dient dan een schriftelijke en ondertekende brief of fax te sturen met daarin het verzoek of bezwaar.



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