Hi,

In my data, I have portfolio id, port_ret, first, date, count, have, and want.

Id is simply the ID of each portfolio.

port_ret is simply the return on the portfolio

first represents when was the first return generated. In the below case, the first return of 0.5 was generated on 27th January 1998

count is simply the number of observations in each id.

"have" is the base value of 100 which starts on 27th January 1998

"want" is simply "have*(1+port_ret)" i.e., 100 * (1+0.5) = 150 for id 2 as we had the first port_ret in id 2

Then what I am looking for next is that "want" should remain 150 for id 2, then for next id, i.e., id 3, it should increase by 150(1+0.6) = 240, then for id 4 it should again increase by 240(1+0.7) = 408 and so on.

When first is >0, then It should ignore the ids where we do not have even a single value of port_ret. i.e., weekends or public holidays.

Any help would be greatly appreciated.

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input double(id port_ret first date count have want dayofweek)
1  .  0 13905 .   .      . 1
1  .  0 13905 .   .      . 1
1  .  0 13905 .   .      . 1
2 .5  1 13906 1 100    150 2
2  .  2 13906 2   .    150 2
2  .  3 13906 3   .    150 2
3 .6  4 13907 1   .    240 3
3  .  5 13907 2   .    240 3
3  .  6 13907 3   .    240 3
3  .  7 13907 4   .    240 3
4 .7  8 13908 1   .    408 4
4  .  9 13908 2   .    408 4
4  . 10 13908 3   .    408 4
4  . 11 13908 4   .    408 4
4  . 12 13908 5   .    408 4
5 .2 13 13909 1   .  489.6 5
5  . 14 13909 2   .  489.6 5
5  . 15 13909 3   .  489.6 5
6  . 16 13910 1   .      . 6
6  . 17 13910 2   .      . 6
6  . 18 13910 3   .      . 6
7 .3 19 13912 1   . 636.48 1
7  . 20 13912 2   . 636.48 1
7  . 21 13912 3   . 636.48 1
end
format %tdMonth_DD,_CCYY date
label values dayofweek dow
label def dow 1 "Monday", modify
label def dow 2 "Tuesday", modify
label def dow 3 "Wednesday", modify
label def dow 4 "Thursday", modify
label def dow 5 "Friday", modify
label def dow 6 "Saturday", modify