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: panel - rowtotal


From   Benodet Karia <[email protected]>
To   <[email protected]>
Subject   st: panel - rowtotal
Date   Sat, 13 Nov 2010 20:29:08 +0000

Dear All,

I have a panel dataset which shows the sales of the marketing units at particular dates. I have the dates in the first column, codes of the marketing units in the second column and sales of each unit in the third column. Some marketing units have affiliates. The data shows the sales of the marketing units and their affiliates seperately. I just need to sum the sales of the main unit and its affiliates at each date.

For example, say the code of main unit is A, and the codes of the affilliates are B and C. All I need to do is to sum the sales of A, B and C at date1. Then I'll do the same for date2, date3.. etc. Finally, I'll drop B and C. So the sales of unit A will be replaced by A+B+C.

Basicly I tried the commands "foreach date {" "egen units=rowtotal(sales) if code=="A" | code=="B" | code=="C"" but couldnt be successful. Anyone can guide this poor starter student?

 
PS: In some dates, I dont have data for B and C. Rather than zero sales, I simply dont see the data about B and C on some dates. I mean should it be a balanced panel to run the code?

Thanks, bk
  		 	   		  
*
*   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