Dear All, Suppose that I have the following data set
Firstly, I use the code
to find the initial price for each id. Then, for each id, I'd like to find the (first) Date with higher price than the initial price (ip). Any suggestions? Thanks.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float id int Date float price 1 21914 10.67 1 21937 10.22 1 21973 9.7 1 22005 9.07 1 22035 9.04 1 22064 9.72 1 22096 11.47 1 22127 13.19 1 22158 12.28 1 22188 12.14 1 22218 10.05 1 22249 10 2 21914 7.45 2 21937 7.31 2 21973 7.73 2 22005 6.86 2 22035 6.71 2 22064 6.73 2 22096 7.97 2 22127 9.91 2 22158 8.87 2 22188 8.02 2 22218 8.06 2 22249 7.68 3 21914 4.14 3 21937 3.96 3 21973 3.54 3 22005 3.36 3 22035 3.39 3 22064 3.3 end format %tdCCYY-NN-DD Date label values id name label def name 1 "000020", modify label def name 2 "000045", modify label def name 3 "000056", modify
Code:
bys id (Date): egen ip = first(price)

Comment