Quantcast
Channel: Statalist
Viewing all articles
Browse latest Browse all 65064

Get a average of observations in the neighborhood??

$
0
0
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





Viewing all articles
Browse latest Browse all 65064

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>