Bookmark and Share

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]

Re: st: Mean of Std dev over moving window of 3 years


From   Sergiy Radyakin <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Mean of Std dev over moving window of 3 years
Date   Fri, 26 Jul 2013 17:29:25 -0400

1. create a SICgroup variable. Something like
generate str2 sicgroup=substr(string(sic),1,2)
might work, but depends on your data.

2.collapse your data by year and sicgroup.
collapse (sd) cashratio, by(year sicgroup)

3. now you have your timeseries, run the moving average on it.

Best, Sergiy


On Thu, Jul 25, 2013 at 3:12 PM, nouloe ansems <[email protected]> wrote:
> Dear statalist,
>
> My dataset contains 7800 unique companies, with "gvkey" as the a unique identifier.
> For each company i have a certain amount of years in my data. (not the same for each company).
> Next to that I have the variable cashratio, and SIC code.
> With SIC code as a 4 number digit.
>
> Now i have to generate this variable  : The mean of the standard deviations of the cash flow ratio over 3 years for firms in
> the same two-digit SIC-code industry.
>
> Since SIC is a 4 digit number, same 2 digit industry means it has the same first 2 numbers.
>
> I've tried a lot of options, but failed each time. Could somebody pleas give me a hand?
>
> Thanks in advance,
> Niels Ansems
>
> *
> *   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/
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index