Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: @egen and @collapse can not summarize over missing values in columns? #190

Open
gergelyattilakiss opened this issue Aug 13, 2024 · 1 comment
Labels
bug Something isn't working question Further information is requested

Comments

@gergelyattilakiss
Copy link
Collaborator

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

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.

@gergelyattilakiss gergelyattilakiss added bug Something isn't working question Further information is requested labels Aug 13, 2024
@korenmiklos
Copy link
Member

The issue is that all values in a group are missing. So when we do skipmissing, the result will be an empty vector. We may need to special case this. I think we need to return missing in all these cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants