In max(Xid) : no non-missing arguments to max; returning -Inf.

Since your issue is clearly data dependant. Providing sample data would seem a good idea.
There is a useful guide as to how to go about that here