Hello Statalists,

So the dataset is a panel year month HS Codes subject to NTM (Non-tariff Measure) changes. The actual dataset is consist of 8821 HS Codes from 2008-2018. So I want to know how many HS Codes which its NTM status:
1. Never switch from 0
2. Never switch from 1
3. Only once switch from 0 to 1
4. Only once switch from 1 to 0
5. Switched multiple times (distinguished by two switches, three switches, and so on)

Here is the dataex of the dataset.

clear
input str10 HS10_07 float(year month d_NTM)
"0101100000" 2008 1 0
"0101100000" 2008 2 0
"0101100000" 2008 3 0
"0101100000" 2008 4 0
"0101100000" 2008 5 0
"0101100000" 2008 6 0
"0101100000" 2008 7 0
"0101100000" 2008 8 0
"0101100000" 2008 9 0
"0101100000" 2008 10 0
"0101100000" 2008 11 0
"0101100000" 2008 12 0
"0101100000" 2009 1 0
"0101100000" 2009 2 0
"0101100000" 2009 3 0
"0101100000" 2009 4 0
"0101100000" 2009 5 0
"0101100000" 2009 6 0
"0101100000" 2009 7 0
"0101100000" 2009 8 0
"0101100000" 2009 9 0
"0101100000" 2009 10 0
"0101100000" 2009 11 0
"0101100000" 2009 12 0
"0101100000" 2010 1 0
"0101100000" 2010 2 0
"0101100000" 2010 3 0
"0101100000" 2010 4 0
"0101100000" 2010 5 0
"0101100000" 2010 6 0
"0101100000" 2010 7 0
"0101100000" 2010 8 0
"0101100000" 2010 9 0
"0101100000" 2010 10 0
"0101100000" 2010 11 0
"0101100000" 2010 12 0
"0101100000" 2011 1 0
"0101100000" 2011 2 0
"0101100000" 2011 3 0
"0101100000" 2011 4 0
"0101100000" 2011 5 0
"0101100000" 2011 6 0
"0101100000" 2011 7 0
"0101100000" 2011 8 0
"0101100000" 2011 9 1
"0101100000" 2011 10 1
"0101100000" 2011 11 1
"0101100000" 2011 12 1
"0101100000" 2012 1 1
"0101100000" 2012 2 1
"0101100000" 2012 3 1
"0101100000" 2012 4 1
"0101100000" 2012 5 1
"0101100000" 2012 6 1
"0101100000" 2012 7 1
"0101100000" 2012 8 1
"0101100000" 2012 9 1
"0101100000" 2012 10 1
"0101100000" 2012 11 1
"0101100000" 2012 12 1
"0101100000" 2013 1 1
"0101100000" 2013 2 1
"0101100000" 2013 3 1
"0101100000" 2013 4 1
"0101100000" 2013 5 1
"0101100000" 2013 6 1
"0101100000" 2013 7 1
"0101100000" 2013 8 1
"0101100000" 2013 9 1
"0101100000" 2013 10 1
"0101100000" 2013 11 1
"0101100000" 2013 12 1
"0101100000" 2014 1 1
"0101100000" 2014 2 1
"0101100000" 2014 3 1
"0101100000" 2014 4 1
"0101100000" 2014 5 1
"0101100000" 2014 6 1
"0101100000" 2014 7 1
"0101100000" 2014 8 1
"0101100000" 2014 9 1
"0101100000" 2014 10 1
"0101100000" 2014 11 1
"0101100000" 2014 12 1
"0101100000" 2015 1 1
"0101100000" 2015 2 1
"0101100000" 2015 3 1
"0101100000" 2015 4 1
"0101100000" 2015 5 1
"0101100000" 2015 6 1
"0101100000" 2015 7 1
"0101100000" 2015 8 1
"0101100000" 2015 9 1
"0101100000" 2015 10 1
"0101100000" 2015 11 1
"0101100000" 2015 12 1
"0101100000" 2016 1 1
"0101100000" 2016 2 1
"0101100000" 2016 3 1
"0101100000" 2016 4 1
end

Now then, from the dataex, the particular HS Codes only changes once because it began with NTM status 0 from 2008-01 to 2011-08 and changes to 1 from 2011-09 until 2018-12. In the actual dataset, it's very very possible that the NTM status changes from 0 to 1 to 0 to 1 for particular periods of time.

Thank you Statalists.