Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: calculate the standard deviation for a list of lagged values
From
Larry Sen <[email protected]>
To
[email protected]
Subject
st: calculate the standard deviation for a list of lagged values
Date
Wed, 15 Jan 2014 14:37:34 +1100
Hi statalist,
I have a dataset about the firm's sales values in each year. The
structure of my dataset looks like this:
YEAR FIRM_ID SALES
1975 01 100
1976 01 200
1977 01 120
1978 01 130
1977 02 130
1978 02 150
1979 02 160
1980 02 180
1972 03 110
1973 03 130
1974 03 120
1975 03 190
For each observation, I want to calculate the stand deviation of the
sales using the previous ten years sales number. How can I do that?
I tried to use by firm_id: eegen sales_sd=std(sales) in[_n-11]/[_n-1]
But its not working :(.
Thank you!
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/