Announcement

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

  • Dropping missing observations

    I have 5 numeric variables: ed em eg eh en.

    Is there anyway to tell Stata to drop any of the variables where the last 12 observations are missing. They all have to be missing i.e. if only 11 observations are missing then we retain that variable?

    Edit
    *cannot amend title, but should be dropping variables if missing observations.
    Last edited by Hale Isaac; 27 Jul 2023, 02:55.

  • #2
    Last is ambiguous. Below, I assume the observation number defines this.

    Code:
    foreach var of varlist ed em eg eh en{
        qui count if missing(`var') in -12/l
        if `r(N)'==12{
            drop `var'
        }
    }
    Last edited by Andrew Musau; 27 Jul 2023, 03:50.

    Comment


    • #3
      Thank you very much Andrew, that has done the job!

      Comment

      Working...
      X