I am hoping for a bit of help with the generation of a new variable. I have some experience with STATA, but I am still very new to the software.
Although my data contains many variables for this question only three variables are important. Firm, Year, and Score. I am wanting to create a new variable that is the Standard Deviation of the Score variable that lagged by one year and includes the past 3 years scores to compute the standard deviation. This calculation needs to be by firm. I know I may not be communicating this clearly, so I am including some sample data to illustrate my goal.
Firm | Year | Score |
A | 1991 | 90 |
A | 1991 | 95 |
A | 1992 | 96 |
A | 1992 | 92 |
A | 1993 | 93 |
A | 1993 | 94 |
A | 1994 | 96 |
A | 1994 | 93 |
A | 1995 | 95 |
A | 1995 | 94 |
A | 1996 | 94 |
A | 1996 | 87 |
A | 1996 | 93 |
A | 1997 | 94 |
A | 1998 | 90 |
A | 1999 | 90 |
A | 1999 | 97 |
A | 1999 | 91 |
A | 2000 | 92 |
A | 2001 | 92 |
A | 2001 | 87 |
A | 2002 | 94 |
B | 1995 | 89 |
Finally, it is important to note that not every firm's observations are in the same year. For instance, firm B has observations that go back to 1963.
Are there any commands I can use to calculate SDScore in my dataset? Thanks!
Best,
Daniel
0 Response to Help with the creation of a lagged standard deviation variable
Post a Comment