Dear statalist,
I have a panel data from 2010-2019, the variables are Year, Symbol, disclosure and dlist. The disclosure variable takes 3 values, 0, 1, and 2; I create a dlist variable, which aggregates the value of disclosure of a firm each year into a string variable. So what I want is to create an indicator variable, one_zero, which equals 1 if, for a firm in a given year, the value of disclosure switches from 1 to 0. I require before the switch, the firm is always with disclosure==1, and after it switches from 1 to 0, it will keep disclosure==0 for the rest of the sample period. The indicator variable equals 0 for all other cases. Here are some example data
So in the example above, the 2 bolded firm-year should be coded 1 for one_zero. Basically, the firms that meet my desired condition would have the form 111000, the firm can have different numbers of 1s before switching to 0, and can have different numbers of 0s after switching to 0. I believe -strmatch- can do this, can anyone kindly help me with this? Thanks a lot!
I have a panel data from 2010-2019, the variables are Year, Symbol, disclosure and dlist. The disclosure variable takes 3 values, 0, 1, and 2; I create a dlist variable, which aggregates the value of disclosure of a firm each year into a string variable. So what I want is to create an indicator variable, one_zero, which equals 1 if, for a firm in a given year, the value of disclosure switches from 1 to 0. I require before the switch, the firm is always with disclosure==1, and after it switches from 1 to 0, it will keep disclosure==0 for the rest of the sample period. The indicator variable equals 0 for all other cases. Here are some example data
Code:
Year Symbol disclosure dlist 2010 900 1 1111100000 2011 900 1 1111100000 2012 900 1 1111100000 2013 900 1 1111100000 2014 900 1 1111100000 2015 900 0 1111100000 2016 900 0 1111100000 2017 900 0 1111100000 2018 900 0 1111100000 2019 900 0 1111100000 2010 903 0 0000010100 2011 903 0 0000010100 2012 903 0 0000010100 2013 903 0 0000010100 2014 903 0 0000010100 2015 903 1 0000010100 2016 903 0 0000010100 2017 903 1 0000010100 2018 903 0 0000010100 2019 903 0 0000010100 2010 932 1 1100000000 2011 932 1 1100000000 2012 932 0 1100000000 2013 932 0 1100000000 2014 932 0 1100000000 2015 932 0 1100000000 2016 932 0 1100000000 2017 932 0 1100000000 2018 932 0 1100000000 2019 932 0 1100000000 2010 961 0 0002110211 2011 961 0 0002110211 2012 961 0 0002110211 2013 961 2 0002110211 2014 961 1 0002110211 2015 961 1 0002110211 2016 961 0 0002110211 2017 961 2 0002110211 2018 961 1 0002110211 2019 961 1 0002110211
Comment