Announcement

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

  • Drop rows

    Hi!

    I got a list with the row numbers i want to drop from my data set. E.g. row 14400, 14432, 14437, and so on. There are 15891 rows in total.

    Can anyone help me with the command or way of doing this?

    There are to may rows I want to delete to do it manually ..

    Henrik

  • #2
    I would worry about dropping observations based on a row number, as that can change if the file is sorted. It would be much safer if 14400, 14432, etc were unique ids. Having said that, it depends how the list is stored. You could make a separate Stata file, say drop, with a variable n containing those numbers, and sort by n. Then in the main file

    Code:
    gen n = _n
    sort n
    merge 1:1 n using drop
    drop if _merge == 3
    The last line drops observation numbers found in both files.

    Comment


    • #3
      Thanks a lot. This was really helpful I will try!

      Comment

      Working...
      X