Code:
local i 10 local j 20 quietly summ n local t round(`r(max)'/10) forval p = 1/`t'{ sort Date Amihud_Liquidity bysort Date: egen Portfolio`p'= total(Amihud_Liquidity) if Portfolio==. & n>`i' & n<=`j' replace Portfolio = Portfolio`p' if Portfolio==. drop Portfolio`p' local i = `i'+10 local j = `j'+10 }
I basically need the Portfolio variable to be updated every 10 observations. Each Date appears 10+ times, with 10+ values for Amihud_Liquidity.
I need the first 10 values if Amihud_Liquidity added and the constant stored in the first 10 observations for Portfolio. Then the sum of the next 10 Liquidities stored in the next 10 of Portfolio and so on.
n was generated by:
Code:
bysort Date: gen n = _n
0 Response to Loop Error When Mathematical Functions Performed on Local
Post a Comment