Statalist


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

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


From   Kit Baum <baum@bc.edu>
To   statalist@hsphsun2.harvard.edu
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   |   http://ideas.repec.org/e/pba1.html
An Introduction to Stata Programming | http://www.stata-press.com/books/isp.html
   An Introduction to Modern Econometrics Using Stata  |   http://www.stata-press.com/books/imeus.html



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:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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