Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# RE: st: Calculating SD of a variable

 From Nick Cox To "'statalist@hsphsun2.harvard.edu'" Subject RE: st: Calculating SD of a variable Date Fri, 20 May 2011 12:24:24 +0100

```Think more slowly! Unless you want to average over countries, you need to use that too.

You can define 5-year blocks whatever way you want, e.g.

gen quinquennium = 5 * floor(year/5)

and then use

egen sd = sd(gdp), by(countryno quinquennium)

-- but -- and it's your problem not mine -- did you think about using rolling SDs rather than block-based SDs? Blocks are more arbitrary (why start a block in 2000 rather than 1999 or 2001, for example?). Check out -rolling-.

Nick
n.j.cox@durham.ac.uk

lreine ycenna

Thanks.
I should've mentioned that I need 5-year standard deviations of the growth rate.
So I think I need to keep year instead of countryno. The average out
the SD for each 5 years.

On 20 May 2011 12:07, Oliver Jones <ojones@wiwi.uni-bielefeld.de> wrote:

> Am 20.05.2011 13:01, schrieb Oliver Jones:
>
>> Leave out the variable year in the by() option and that should do what
>> you want.
>
> Or leave out the variable countryno.
> It depends on your aim:
> - sd over time for each country , or
> - sd over countries for each year
>

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```