Hello Statalist!
I am currently struggling to find a solution to keeping firms defined as at-risk. I have panel data with hqduns and year. In some years, the firms are detected making violations whereas in others they are not. I need to keep all the years for firms that make any violation in any given year. For example, say a firm makes a violation in 2010 but not in any other year. I want to keep all firm-year observations of all firms that made at least one violation at any point in my sample year.
Below is an example of a firm that made a violation in 2010 but not any other year. My full sample includes firms that never make any violation, and I only want to keep ones that were found making at least one violation in any given year.
Thank you!
I am using Stata 16.1 MP
I am currently struggling to find a solution to keeping firms defined as at-risk. I have panel data with hqduns and year. In some years, the firms are detected making violations whereas in others they are not. I need to keep all the years for firms that make any violation in any given year. For example, say a firm makes a violation in 2010 but not in any other year. I want to keep all firm-year observations of all firms that made at least one violation at any point in my sample year.
Below is an example of a firm that made a violation in 2010 but not any other year. My full sample includes firms that never make any violation, and I only want to keep ones that were found making at least one violation in any given year.
Code:
* Example generated by -dataex-. For more info, type help dataex clear input long hqduns int year byte(safetyrelatedoffenses environmentrelatedoffenses employmentrelatedoffenses financialoffenses otheroffenses) 1000355 1999 0 0 0 0 0 1000355 2000 0 0 0 0 0 1000355 2001 0 0 0 0 0 1000355 2002 0 0 0 0 0 1000355 2003 0 0 0 0 0 1000355 2004 0 0 0 0 0 1000355 2005 0 0 0 0 0 1000355 2006 0 0 0 0 0 1000355 2007 0 0 0 0 0 1000355 2008 0 0 0 0 0 1000355 2009 0 0 0 0 0 1000355 2010 0 1 0 0 0 1000355 2011 0 0 0 0 0 1000355 2012 0 0 0 0 0 1000355 2013 0 0 0 0 0 1000355 2014 0 0 0 0 0 end
I am using Stata 16.1 MP

Comment