Announcement

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

  • why the drop code drops more obs than it should have been?

    I have a variable called A, when I use the code sum A if A>20000, I read the outcome showing there are 80 obs. But when I use the code drop if A >100000, it tells me 1200 obs have been deleted. I can't figure it out why. Anybody help? Thanks a lot

  • #2
    Remember that in Stata, missing values are considered to be larger than any real number. So -drop if A >100000- will drop any observation where A is a real number > 100000 and will also drop any observation where A is missing. By contrast, -summ A if A > 20000- ignores missing values of A and only works with real numbers > 20000.

    If you want to drop observations where A is a real number > 100000 but not drop those where A is missing, the command is:
    Code:
    drop if A > 100000 & !missing(A)

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      Remember that in Stata, missing values are considered to be larger than any real number. So -drop if A >100000- will drop any observation where A is a real number > 100000 and will also drop any observation where A is missing. By contrast, -summ A if A > 20000- ignores missing values of A and only works with real numbers > 20000.

      If you want to drop observations where A is a real number > 100000 but not drop those where A is missing, the command is:
      Code:
      drop if A > 100000 & !missing(A)
      thanks for your reply! I do appreciate that.

      Comment

      Working...
      X