Bookmark and Share

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

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

st: Identify and delete duplicate obs

From   Rongrong Zhang <>
Subject   st: Identify and delete duplicate obs
Date   Thu, 26 Dec 2013 09:12:00 -0500


my dataset has the following structure

industrynumber   naics
1000                     .
1001                      114
100101                  114
100102                   114

both variables are string .
the first observation has a missing value for naics. observations
sharing the same four digit (e.g. 1001) will have the same naics, I
would like to keep one observation only for the same naics

i used
bysort naics: gen dup=cond(_N==1, 0, _n)

this command will count missing naics as well, I have thousands of
missing naics records, in which case, dup is a large number.

how should I replace dup value when the observation is missing naics??

this did not work"replace  dup=-1 if naics==" "

thank you,
*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index