Notice: On March 31, it was **announced** that Statalist is moving from an email list to a **forum**. The old list will shut down on April 23, and its replacement, **statalist.org** is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Nick Cox <n.j.cox@durham.ac.uk> |

To |
"'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |

Subject |
st: RE: Calculating SD of a variable |

Date |
Fri, 20 May 2011 12:05:22 +0100 |

If you fire up -egen, sd()- using the option -by(countryno year)- then the combinations of country and year correspond to single observations. There can be no variability in a single observation, but what overrides that zero is that the SD calculation uses (n - 1) rather than n in the divisor, so n - 1 = 0 in that case and missing results are thus shown. Your problem remains vaguely stated, but note that SDs for countries would be egen SD = sd(gdp), by(countryno) and -- in general -- that the -by()- option defines groups within which SD is calculated. Nick n.j.cox@durham.ac.uk lreine ycenna I have a list of countries and their annual GDP growth rates. I need to calculate the standard deviations of the growth rate. But I seem to have done it wrong: Using the command egen sd = sd(gdp) gives me the same number for the entire column Using egen sd= sd (gdp), by(countryno year) gives me missing values. Am I missing something? My panel data looks like this: countryno year gdp 122 1995 1.448922432 122 1996 1.802327838 122 1997 1.939189289 122 1998 3.486108757 122 1999 3.057156394 122 2000 3.403232592 122 2001 0.706544087 122 2002 0.572674299 122 2003 0.806288363 122 2004 2.143516615 122 2005 2.0000 122 2006 3.021230987 124 1970 6.058892112 124 1971 3.1155209 124 1972 4.699826137 124 1973 6.212549621 124 1974 4.21133101 124 1975 -2.174872486 124 1976 5.612220928 124 1977 0.585991929 124 1978 2.844723097 etc.. * * 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/

**References**:**st: Calculating SD of a variable***From:*lreine ycenna <lreine.ycenna@gmail.com>

- Prev by Date:
**st: Xtivreg2 random effects model** - Next by Date:
**Re: st: Calculating SD of a variable** - Previous by thread:
**st: Calculating SD of a variable** - Next by thread:
**Re: st: Calculating SD of a variable** - Index(es):