Announcement

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

  • Drop individuals who have too many missings

    Hello everyone,

    I think this is quite a simple question but I am still not very used to STAT

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input int pid byte(age_45 age_46 age_47 age_48 age_49 age_50)
    101 1 2 . . 4 .
    102 2 2 3 3 5 4
    103 . . . . . .
    104 . . 1 1 1 1
    105 2 5 5 5 4 .
    end
    This is my data format. Every individuals occupies one line (i.e. wide format) and from age_45 to age_50 refers to one's employment status at each year.
    I want to drop pid who has more than 3 missings.

    I think I should use 'egen' but not sure

    Thank you for your help!


    Halim.

  • #2
    You could probably do it in one line, but it's easier to see in a couple.
    Code:
    egen byte miss_count = rowmiss(age_*)
    drop if miss_count > 3

    Comment


    • #3
      Thank you very much Joseph!

      Comment

      Working...
      X