Hello everyone,


I have a time variable which is given as a difference. So if there is a starting date, say, 6/6/16. My days are represented by another date (different for different observations) minus 6/6/16. Therefore, the first week is represented by 7 and below. The second week is above 7 but below 14 etc.


How do I generate a new variable which represents average price of each week?

i.e, how can I generate Avweeklyprice on Stata?

Price Time Avweeklyprice
2 7 3.5
6 12 7
8 13 7
2 22 2
5 2 3.5
Note: My actual data has time ranging from 30 to -15.