Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: How to roll up data with a time window and condition


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: How to roll up data with a time window and condition
Date   Mon, 7 Nov 2005 18:42:50 -0000

. ssc desc mvsumm
. ssc inst mvsumm 
. help mvsumm 

Nick 
[email protected] 

Lynda Zhang
 
> I would like to roll up the past 4 quarters of sales for each company:
> 
> Company  Year Quarters  Sales  4_Mo_Sales
> ABC      1990  1         10
> ABC      1990  2         10
> ABC      1990  3         15
> ABC      1990  4         10     45
> ABC      1991  1         20     55
> BBC      1989  1         20    
> BBC      1989  2         10  
> BBC      1989  3         20
> BBC      1989  4         10     60
> BBC      1990  1         15     55
> BBC      1990  3         10     35
> 
> The resulting calculation I am looking to get is in 4_Mo_Sales.
> 
> Note the following:
> 
> 1) The first 3 quarters don't have 4 full quarters, so I don't 
> calculate the 4_Mo_Sales for that 3 quarters
> 
> 2) For BBC, quarter 2 in 1990 is missing, so I only sum up 3 quarters 
> and got 35 in the past 4 quarters
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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