I have the following code to produce example data and to reproduce my problem:
When running the second mode() command
at least Stata 18 and Stata 19.5 throw the error specified in the comment:
"Multiple modes encountered in one or more groups."
However, as you can see if you run this example, there are absolutely no multiple modes encountered in any bysort group at variable modeflag. I believe this should be fixed, as it has caused me to do unnecessary verifications to find out there were no multiple modes. Am I missing something here?
Best regards,
Kasper
Code:
clear input id year status target 1 2001 0 2 1 2002 1 2 1 2003 1 2 1 2004 1 4 1 2005 0 3 2 1999 1 4 2 2000 1 4 2 2001 1 5 2 2002 0 1 2 2003 1 5 3 2004 0 3 3 2005 1 . 3 2006 1 . 3 2007 1 . 3 2008 1 . 3 2009 0 . end bysort id: egen modeflag = mode(target) if status==1, minmode bysort id: egen modefinal = mode(modeflag) /* warning: Multiple modes encountered in one or more groups. Generating missing values for the modes in these groups. Use option minmode, maxmode, or nummode() to select one of the modes. (6 missing values generated) */
When running the second mode() command
Code:
bysort id: egen modefinal = mode(modeflag)
"Multiple modes encountered in one or more groups."
However, as you can see if you run this example, there are absolutely no multiple modes encountered in any bysort group at variable modeflag. I believe this should be fixed, as it has caused me to do unnecessary verifications to find out there were no multiple modes. Am I missing something here?
Best regards,
Kasper

Comment