Good evening,
I am working on my thesis regarding the capital structure of firms and I am having troubles to create the standard deviation of a variable that i need. I have to calculate the standard deviation for each year and for each firm. Afterwards I have to take an average of 3 years for each firm (e.g Firm 1, I need to obtain the Average Std for year 2005-2008,2006-2009 and so on).
so far i have tried the following command:
sort firm year
egen SD=sd (business risk), by (firm year)
but i received missing variables. Then I tried the following:
sort firm year
egen SD=sd(business risk) if firm[ _n]=firm[ _n-1], by(year)
In this case, I end up having missing variables for the first year in each firm and I also doubt about the results that i receive.
Thank you in advance for your help and for your time.
With kind regards,
Fotis Psipsilis
I am working on my thesis regarding the capital structure of firms and I am having troubles to create the standard deviation of a variable that i need. I have to calculate the standard deviation for each year and for each firm. Afterwards I have to take an average of 3 years for each firm (e.g Firm 1, I need to obtain the Average Std for year 2005-2008,2006-2009 and so on).
so far i have tried the following command:
sort firm year
egen SD=sd (business risk), by (firm year)
but i received missing variables. Then I tried the following:
sort firm year
egen SD=sd(business risk) if firm[ _n]=firm[ _n-1], by(year)
In this case, I end up having missing variables for the first year in each firm and I also doubt about the results that i receive.
Thank you in advance for your help and for your time.
With kind regards,
Fotis Psipsilis
Comment