Hi!
I have a panel dataset of companies, with observations for Sales for each year. I would like to generate a new variable (delta_2005-2001) displaying the difference in Sales for company 1 between year 2005 and 2001, and similarly the difference for company 2, 3, etc. Some companies have missing values, so I cannot write n-5 or the like. I have made an example of my dataset below. I tried this command:
egen delta_2005-2001 = Sales if Year==2005 - Sales if Year==2001 , by(Company)
But that did not work.
Do you have any suggestions? Any help would be greatly appreciated!

Array