Hello everyone,

I'm trying to generate a proper diversification variable from my data. What I want this variable to do is to count exactly the number of investments that the investor has in the portfolio and when an investment reaches the maturity, it will automatically will substract these investments that have reached maturity. My data looks like the following

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long(Investor Investment) float BiddingTime byte Maturity float diversification
3    1  13oct2010 08:51:10  3 .
3    3 14oct2010 03:05:38  3 1
3   26  29oct2010 04:00:54  3 2
3   43  11nov2010 16:29:28  3 3
3   50  11nov2010 16:29:28  3 4
3  209 01dec2010 14:56:25  6 4
3  258  09dec2010 16:25:02  3 5
3  247 09dec2010 16:29:2412 5
3  413 22dec2010 04:14:40  3 5
3  477  23dec2010 11:15:53  3 6
3 1866 13feb2011 05:03:46 12 6
3 1910 13feb2011 05:03:46  6 7
3 5103  15may2011 07:00:57 12 7
3 6397 07jun2011 07:02:51  3 7
end
format %tc BiddingTime
The number diversification is the cumulative number of successful investments that goes into the investors portfolio. Maturity is the number of months until the investment reaches maturity where for example 3 = 3 months. Investor is the Investor ID and Investment is the Investment ID. Also, I edited BiddingTime by myself because when I use dataex it gives me numbers like these 1.602579e+12.
I would be thankful if someone can help.

Thank you for your time.