Hi all,
A new egen function is now available on SSC (thanks to Christopher Baum). _gdistinct works with egen to generate a count of the distinct values of a variable list and takes a by option.
Type ssc install _gdistinct to download the package.
Then, you can run commands such as:
Type help _gdistinct for more information.
After using routines like this several times in my work, I figured that this might be useful to others.
A new egen function is now available on SSC (thanks to Christopher Baum). _gdistinct works with egen to generate a count of the distinct values of a variable list and takes a by option.
Type ssc install _gdistinct to download the package.
Then, you can run commands such as:
Code:
bysort varlist1: egen int newvar = distinct(varlist2)
After using routines like this several times in my work, I figured that this might be useful to others.
Comment