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]

Re: st: list duplicates but within subgroups

From   Nick Cox <>
Subject   Re: st: list duplicates but within subgroups
Date   Fri, 31 Dec 2010 09:45:28 +0000

Nick Sanders' advice is good.

In essence, the options of the -list- command allowed with
-duplicates- are to be thought of as cosmetic or presentational. But
they don't include -by()- or -over()- which are not options of either
-list- or -duplicates-, as the help makes clear.

The logic is that you want to check whether school code and id are
joint identifiers, and so as far as -duplicates- is concerned they
have equal standing.

Nick Cox

Nick Sanders wrote

Perhaps I'm not understanding, but I believe the command is even
easier than those you've suggested. Try:

"duplicates list school id"

That should list any duplicates of school AND id, which I think is
what you want. If you have a bunch of data, I might suggest

"duplicates tag school id, gen(dupes)"

rather than list. Then "browse if dupes ~= 0" and you'll see all your duplicates

Michael Costello

> I have a poorly coded dataset that was typed from several thousand
> paper surveys.  Often a stack of surveys would be entered into the
> computer and then later entered again because of poor record keeping.
> Each survey has two variables of interest, school_code and id.
> Neither is unique, but there should be only one of each id in each
> school_code.  For example, I should not have two children at
> school_code=10 who both have the same id number, yet there will be
> students at every school who have id=1, 2, etc.
> I'm trying to find a command that uses some kind of subgroup option
> for a -duplicates list- command.  I've tried all the easy ones
> ("duplicates list id, by school", "duplicates list id, over school",
> "duplicates list id, sepby(school_code)" ) all with no luck.  Does
> anyone have any ideas of commands, macros, or websites that might help
> me with this?  Thanks for your help.

*   For searches and help try:

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