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

st: Re: How to generate "total" observation?

From   Kit Baum <>
Subject   st: Re: How to generate "total" observation?
Date   Sun, 2 Aug 2009 07:25:56 -0400

How about generating a total variable?

egen sumvar1 = sum(var1), by(id)

or use -collapse- with the -by- option to (temporarily: see -help preserve-) create a dataset of totals.

If doing this on the fly is enough, -help tabstat-. E.g.

tabstat var1, by(id) stat(sum)

Kit Baum   |   Boston College Economics & DIW Berlin   |
An Introduction to Stata Programming |
   An Introduction to Modern Econometrics Using Stata  |

On Aug 2, 2009, at 02:33 , statalist-digest wrote:

I have a (possible) dummy question. I have a panel data set like the following:

id  year var1
01 2000 10
01 2001 20
02 2000 15
02 2001 25

I want to create a new observations, with id=03, that sum the var1
over the other ids. Obviously, I'm no going to use this observations
to make some estimation, but total statistics. How can I generate this
aditional observations.

*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index