I am working with firm-level panel data with a firm identifier (ident) and a year variable (year). For the same firm (here ident=102) and for different years (year=2010-2013), I have values on four variables (X1-X4). I would like to write a code that generates for each firm (here ident=102) and for all the years a new variable that contains the maximum (non-missing) value in the matrix, that is 5. I used the code egen new=rowmax(X1-X4) but it didn't work. Any suggestion is welcome.
ident | year | X1 | X2 | X3 | X4 |
102 | 2010 | 2 | 3 | 4 | 5 |
102 | 2011 | 2 | 3 | 4 | . |
102 | 2012 | 2 | 3 | . | . |
102 | 2013 | 2 | . | . | . |
Comment