Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Stop dofile if drop did not make change

    Dear Statalists,

    for error-checking in many replace commands, I have found it useful to use the program described in this post: https://www.statalist.org/forums/for...-not-in-a-loop

    Does somebody know of a similar solution for drop-commands?

    Thank you!

  • #2
    Code:
    clear all
    
    
    program mydrop
        drop `0'
        capture assert r(N_drop) != 0
        if _rc {
            di as err "no observations dropped"
            exit(_rc)
        }
    end
    
    sysuse auto
    mydrop if foreign == 1
    mydrop if foreign == 3
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      Ah wow, that was easy. I thought I would have to construct the 'N_drop' myself. Thank you!!

      Comment

      Working...
      X