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: detecting repeated observations

From   Nick Cox <>
Subject   Re: st: detecting repeated observations
Date   Mon, 14 Jan 2013 12:08:28 +0000

Your comparison

... if artist != artist

compares each value with itself, but necessarily in no observations
are values not equal to themselves. It is like asking

...  if "Estrella" != "Estrella"

which is always false.

Your comparison needs to be within a group of observations.

bysort title (artist) : gen diff = artist[1] != artist[_N]
l title artist if diff

This is an FAQ: see

I did refer you to precisely this FAQ on 9 January.


On Mon, Jan 14, 2013 at 11:58 AM, Estrella Gomez
<> wrote:
> Hi,
> I am working with a database that contains music records. I would like
> to detect observations in which the title is the same title but the
> artist is different; for instance, "The power of love" is a song from
> Celine Dion, but also from Huey Lewis & the News. I have tried this
> command:
> list if title==title & artist!=artist
> but reports nothing.
> In addition, I would like to find observations with the same title but
> different identifier; however,
> list if title==title & id!=id
> again reports nothing
> Any idea?
*   For searches and help try:

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