I have the data of products as the following
ID::::::1 2 3 4 5 ... .... 100
Size:::2 3 5 6 7 ... ... 88
Price::9 6 7 8 5 ... ... 6
I want to calculate the average price of observations that are one unit close to each other in terms of their size. How can I code it in stata?
For example,
The average price for product 4 is the average price of product 3 and 5. Because product 3 size is one unit lower than product 4 while product 5 size is one unit higher than product 4
(It is possible that there is less than 2 products in the size neighborhood)
Thanks for the help![Smile]()
ID::::::1 2 3 4 5 ... .... 100
Size:::2 3 5 6 7 ... ... 88
Price::9 6 7 8 5 ... ... 6
I want to calculate the average price of observations that are one unit close to each other in terms of their size. How can I code it in stata?
For example,
The average price for product 4 is the average price of product 3 and 5. Because product 3 size is one unit lower than product 4 while product 5 size is one unit higher than product 4
(It is possible that there is less than 2 products in the size neighborhood)
Thanks for the help
