mcaceresb / stata-gtools

Faster implementation of Stata's collapse, reshape, xtile, egen, isid, and more using C plugins
https://gtools.readthedocs.io
MIT License
182 stars 38 forks source link

gunique missing scalars when there are no observations #75

Closed NilsJPWerner closed 3 years ago

NilsJPWerner commented 3 years ago

Describe the bug gunique handles no observations differently from unique. Unique return 0 for its scalars in the case of no observations, while gunique returns nothing.

Code Sample

. sysuse auto, clear
(1978 Automobile Data)

. unique foreign if make == "audi"
Number of unique values of foreign is  0
Number of records is  0

. di r(sum)
0

. di r(N)
0

. gunique foreign if make == "audi"
(no observations)

. di r(unique)
.

. di r(J)
.

. di r(N)
.

Version info