Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[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" <[email protected]>
To   <[email protected]>
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: [email protected] [mailto:[email protected]] On Behalf Of [email protected]
Sent: Sonntag, 1. August 2010 06:47
To: [email protected]
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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index