Announcement

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

  • Ignoring missing value in egen max

    Dear all,

    I have a panel data and would like to create a dummy variable using the following:
    bys bvd_id: egen filter=max(X>16 & year==2018); however, if the observation of X in 2018 is missing (.), then egen also generates 1, instead of 0. How can I treat that missing value as zero? I tried the following:

    bys bvd_id: egen filter=max(missing(X>16 & year==2018)); This slightly works, but now if I have a missing value for year other than 2018, then the result is also 0.

    Really appreciate your help.


    Best,

    Abdan

  • #2
    Various ways to do it: here is one

    Code:
    bys bvd_id: egen filter=max(X > 16 & X < . & year == 2018)

    Comment


    • #3
      Many thanks for your help!

      Comment

      Working...
      X