Dear experts,
I have a dataset like below. I'd like to count distinct firm numbers by province. For example, although I have six observations in province A in total, I just want to count the distinct firm number by the province which means there should be only three distinct firms (11, 12, 13) in province A. Thank you very much for helping!
I have a dataset like below. I'd like to count distinct firm numbers by province. For example, although I have six observations in province A in total, I just want to count the distinct firm number by the province which means there should be only three distinct firms (11, 12, 13) in province A. Thank you very much for helping!
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input int year byte firm str1 province 2001 11 "A" 2002 11 "A" 2003 11 "A" 2001 12 "A" 2002 13 "A" 2002 13 "A" end
Comment