When I use columns that have missing values to calculate something in a groupby it seems to throw error. E.g:

On the above df if I run
@with df @egen birt_year = minimum(birth_year), by(person_id)
I get
ERROR: MethodError: reducing over an empty collection is not allowed; consider supplying `init` to the reducer
But if I run
@with df begin
@mvencode birth_year, mv(99999)
@egen byear = minimum(birth_year), by(person_id)
end
It throws no error.