Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Looping through observations

From   Laurie Molina <[email protected]>
To   [email protected]
Subject   st: Looping through observations
Date   Mon, 22 Nov 2010 13:50:05 -0600

Hello all,
Hope you are going well.

I am trying to do some calculations with a data set, but i am not very
familiar to stata programming.
The data set is about the time required achive a desired amount of saving.
For each observation in the data set, i have income, and saving rate.
But future income depends on the saving rate.

If i had only one observation i would do the following:

**** (I will omit the quotation marks of local variables).
local savings=0
local counter=0
while savings<10000 {
local counter=counter+1
local savings= income*savingsrate
income= income+ savings*(1+interestRate)

di counter
But now, what i want to do is to create a variable, that contains, for
each observation the required time to achieve the desired amont of

In adition, i will use a huge data base (about 7,000,000 observations)
so i would like to need to create the minumum number of additional

I will appreciate any suggestions.

Thank you very much in advance!!

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index