Statalist The Stata Listserver


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

Re: st: drop question


From   "Sergio Correia" <[email protected]>
To   [email protected]
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.

Best,

Sergio

On 3/8/07, Morrison Hodges <[email protected]> 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?
Thanks

Morrison Hodges, MD
Professor Emeritus of Medicine
University of Minnesota

Senior Investigator
Minneapolis Heart Institute Foundation

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

[email protected]
http://www.mplsheartfoundation.org

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:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/

*
*   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