In the rows I have many many observations
In the columns I have variables X & Y.
X takes values 1-5000, and Y is some price.
I want to create a 3rd column which takes values:
1 if the price is in the top 5% of prices for whatever X value that row has.
E.g. if the row is X=1, Y=9999, I want the 3rd cell to be =1 if out of all rows with X=1, 9999 is in the top 15% of Y's in those rows.
Hope that makes sense.