Bookmark and Share

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]

st: RE: summation of values within one column in a panel dataset


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: summation of values within one column in a panel dataset
Date   Sun, 1 Aug 2010 10:12:18 +0200

<>

***********
clear*

inp comp:mylabel int(profit date), auto 
A      120     2000
A     320   2001
B     102    2000
B     101     2001
C    156     2000
C     136     2001
end

bys date: egen profita_and_b=total(inlist(comp,1,2)*profit) /* 
*/ if inlist(comp,1,2)
so comp date
list, noobs sepby(comp)  
***********

Try NJC`s http://www.stata-journal.com/sjpdf.html?articlenum=pr0004


HTH
Martin

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of rado645-bg@yahoo.de
Sent: Sonntag, 1. August 2010 06:47
To: statalist@hsphsun2.harvard.edu
Subject: st: summation of values within one column in a panel dataset

I have a panel dataset and I wonder if it is possible to generate in  Stata a 
new variable that is the sum of observations for a  variable for two of my 
panels only (ie it is a summation of values  within one column).

example: my panels are companies A,B,C.... and I have quarterly observations on 
profits, revenues, etc. 


Date    company    profits

comp    profit        date
A             120        2000
A            320      2001
B            102       2000
B            101        2001
C           156        2000
C            136        2001


Since company A and B merged in 1999, I need to use the sum of their profits for 
my analysis in years 2000 and 2001. So I need to build a new variable A+B:

comp    profit        date
A+B       122       2000
A+B       421         2001

Is there a command for panel dataset  in Stata that allows me to do  such data 
manipulation (panels are  unbalanced, btw)? Unfortunately, I couldn't find any 
information in the  manuals and on internet. Many thanks in advance!

Best regards,
Radovan



*
*   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   |   Site index