Hello,

I have a question that is a bit complicated for me to solve.
First of all, here's the example data set.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(hotel_id time price booking_1 booking_2 booking_3 booking_4 booking_5 booking_6 booking_7 booking_8 booking_9 booking_10)
1  1  25 1 1 1 1 0 0 0 0 0 1
1  2  25 1 1 1 0 0 0 0 0 1 1
1  3  27 1 1 0 0 0 0 0 1 1 0
1  4  28 1 0 0 0 0 0 1 1 0 0
1  5  28 0 0 0 0 0 1 1 0 0 1
1  6  28 0 0 0 0 1 1 0 0 1 1
1  7  28 0 0 0 1 1 0 0 1 1 1
1  8  29 0 0 1 1 0 0 1 1 1 1
1  9  29 0 1 1 0 0 1 1 1 1 0
1 10  29 1 1 0 0 1 1 1 1 0 0
2  1 100 1 1 0 0 1 1 0 0 0 0
2  2 110 1 0 0 1 1 0 0 0 0 1
2  3 110 0 0 1 1 0 0 0 0 1 1
2  4 110 0 1 1 0 0 0 0 1 1 0
2  5 110 1 1 0 0 0 0 1 1 0 0
2  6 115 1 0 0 0 0 1 1 0 0 1
end

Please note that this is a mock data set.

hotel_id: unique id assigned to each hotel.
time: simply put, let's say it's a daily variable.
price: price for each day for each hotel.
booking_i: dummy variable equals to 1 if a hotel is booked on that day or 0 if not booked.
(Why do I have more than booking_1? -> In this data set, booking information were collected up to future 10 days)

Goal:
My goal is to construct a new variable that represents the average revenue(price*booking) on a 5-day rolling basis (something like moving average).
For example,
the value for hotel 1 in time 1 will be, 25*1+25*1+27*1+28*1+28*0
the value for hotel 1 in time 2 will be, 25*1+27*1+28*1+28*0+28*0
...
the value for hotel 1 in time 10 will be, 29*1+29*1+29*0+29*0+29*1 ...(future price is not achievable for some of the latter observations, so simply put, let's just assume that we can impute the last price.)

the value for hotel 2 in time 1 will be, 100*1+110*1+110*0+110*0+110*1
the value for hotel 2 in time 2 will be, 110*1+110*0+110*0+110*1+110*1
the value for hotel 2 in time 3 will be, 110*0+110*0+110*1+110*1+115*0
the value for hotel 2 in time 4 will be, 110*0+110*1+115*1+115*0+115*0
the value for hotel 2 in time 5 will be, 110*1+115*1+115*0+115*0+115*0
the value for hotel 2 in time 6 will be, 115*1+115*0+115*0+115*0+115*0


Thinking in a simple way, what I can do is to multiply the first 5 observations of price variable with corresponding booking_i variables.
I was thinking of using reshape command so that I can convert price variable to wide format but I can't think of the next steps and just hangs there for a couple of hours..
Is there any better way to implement this?
I would greatly appreciate for any helps.