之前有帖子提过相似问题,但需要sort,我的数据量太大,而且时间段很多,sort起来太慢了
我自己的想法是:
forv i=1/n{
gen id=_n if daily<=0 & daily>=60 & stock==z
egen maxc=max(Clsprc) if id!=.
replace maxc_id=id if maxc==Clsprc
}
但我不知道怎么把id赋值给第一个观测值?
求问各位高手该怎么编程?
sort period time
by period: egen max = max(Clsprc)
gen date = time if Clsprc)==max
sort period date
by period: replace date=date[_n-1] if _n>1
sort period time