Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Egen Variance

    Hey!

    I am trying to check the variance of one of my variables by age of the individuals. I have a cross-section, not a panel. I would like to do something like:

    egen varxx = var(xx) , by(age)

    in the same way that you can do this for the mean. Is it possible to find a similar command?

    Thanks in advance!

  • #2
    No, there is no -egen- function to calculate variance. Not in official Stata, nor in the -egenmore- package. But variance is just the square of standard deviation. So:

    Code:
    egen varxx = sd(xx), by(age)
    replace varxx = varxx*varxx

    Comment

    Working...
    X