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

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


From   Lynda Zhang <[email protected]>
To   [email protected]
Subject   st: How to roll up data with a time window and condition
Date   Mon, 7 Nov 2005 13:28:22 -0500

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

Thanks so much!

Lynda

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