I would like to get the count of distinct units (co_code in my case) based on say each year (how many distinct units are there in each year). I tried user written command distinct, but it doesn't work with option-by-
Here is my sample data
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long co_code int year float(ncfo eqissue) 11 2000 . . 11 2001 . . 11 2002 . . 11 2003 . . 11 2004 . . 11 2005 . . 11 2006 . . 11 2007 . . 11 2008 . . 11 2009 .6 60.3 11 2010 21.1 -6.9 11 2011 2.3 .3 11 2012 127.4 51.5 11 2013 445.8 83.5 11 2014 367.5 70 11 2015 303 . 11 2016 254.2 49 11 2017 444.7 . 11 2018 605.7 -2.1 11 2019 533.6 -1.1 11 2020 447.4 . 11 2021 520.4 -.2 96387 2000 . . 96387 2001 . . 96387 2002 . . 96387 2003 . . 96387 2004 39.7 .1 96387 2005 285.4 1.8 96387 2006 263.8 1554.7 96387 2007 1167.6 10.3 96387 2008 2910.6 -123.1 96387 2009 5906.6 12 96387 2010 3422.3 3097.8 96387 2011 2991.6 1664.9 96387 2012 -1544.6 . 96387 2013 494.8 -164.2 96387 2014 497.6 . 96387 2015 -513.2 . 96387 2016 1990.6 . 96387 2017 1294 . 96387 2018 . . 96387 2019 1370.3 . 96387 2020 1685.8 . 96387 2021 . . 36277 2000 . . 36277 2001 . . 36277 2002 . . 36277 2003 . . 36277 2004 . . 36277 2005 . . 36277 2006 . . 36277 2007 . . 36277 2008 . . 36277 2009 . . 36277 2010 . . 36277 2011 . . 36277 2012 . . 36277 2013 . . 36277 2014 . . 36277 2015 . . 36277 2016 . . 36277 2017 . . 36277 2018 361.9 . 36277 2019 2529.9 . 36277 2020 2450.5 . 36277 2021 3210.7 . 491859 2000 . . 491859 2001 . . 491859 2002 . . 491859 2003 . . 491859 2004 . . 491859 2005 . . 491859 2006 . . 491859 2007 . . 491859 2008 . . 491859 2009 . . 491859 2010 . . 491859 2011 . . 491859 2012 . . 491859 2013 . . 491859 2014 . . 491859 2015 . . 491859 2016 . . 491859 2017 . . 491859 2018 . . 491859 2019 . . 491859 2020 . . 491859 2021 . . 73119 2000 . . 73119 2001 . . 73119 2002 . . 73119 2003 . . 73119 2004 158.7 231.1 73119 2005 1098.4 763.1 73119 2006 3122.2 2221.2 73119 2007 1258.8 -34.8 73119 2008 -2962.1 4558.2 73119 2009 -1883.8 50 73119 2010 -413.4 191.3 73119 2011 -4878.9 . end
. distinct co_code, by (year)
option by() not allowed
How to get distinct count with one or more criteria?
0 Response to Count of distinct units in a panel with "by" option
Post a Comment