Statalist The Stata Listserver

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

Re: st: drop question

From   "Sergio Correia" <>
Subject   Re: st: drop question
Date   Thu, 8 Mar 2007 18:39:05 -0500

This answer is not "elegant" but it works:

gen dropthis = (class[_n+1]>0 | class[_n]>0 | class[_n-1]>0 | class[_n-2]>0)
drop if dropthis

Of course, you can put all that in one line.

Other options might make use of time-series operator but I don't want
to mess up any tsset you may have specified.



On 3/8/07, Morrison Hodges <> wrote:
I want to drop row x-1, x, x+1 and x+2 if the variable 'class' on row x is >
0. It doesn't matter if class is > 0 on rows x+1 and x+2. How can I do this?

Morrison Hodges, MD
Professor Emeritus of Medicine
University of Minnesota

Senior Investigator
Minneapolis Heart Institute Foundation

612-863-2490 (fax)
612-889-7695 (mobile)
612-654-8087 (pager)

The reasonable man adapts himself to the world; the unreasonable
man persists in trying to adapt the world to himself. Therefore, all
progress depends on the unreasonable man.

George Bernard Shaw (1856 - 1950)
Irish writer

*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index