Statalist


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

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


From   Jeetendra Aryal <jeetendra.aryal@umb.no>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: How to generate "total" observation?
Date   Sun, 2 Aug 2009 09:52:59 +0200

Though it may not be a good solution, Hope it helps:
.use a.dta, clear   
.collapse (sum) id var1, by(year)
.save b.dta
.use a.dta, clear
.append using b.dta

rgds,

____________________________________
From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] On Behalf Of Christian Bustamante [cdeb77@gmail.com]
Sent: Sunday, August 02, 2009 9:22 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: How to generate "total" observation?

Thanks for your answer.
The collapse command not was I'm looking for. I need a command that
returns me something like:

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

Where 00 is the "id" of the sum over ids by year.

Bests

On Sun, Aug 2, 2009 at 1:51 AM, Jeetendra Aryal<jeetendra.aryal@umb.no> wrote:
> Have you tried the following command?
> . collapse var1, by(id)
>
> rgds,
> Jeetendra
>
>
>
> ________________________________________
> From: owner-statalist@hsphsun2.harvard.edu [owner-statalist@hsphsun2.harvard.edu] On Behalf Of Christian Bustamante [cdeb77@gmail.com]
> Sent: Sunday, August 02, 2009 7:48 AM
> To: Statalist
> Subject: st: How to generate "total" observation?
>
> Hi all,
> 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.
>
> Thanks
>
>
>
>
> --
> CdeB
> *
> *   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/
> *
> *   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/
>



--
CdeB

*
*   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/
*
*   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