Info:
Win 7 - 64bit
Stata 12.1 SE
12GB RAM / i5 - maschine
Dear All,
I have a set 245.000 loans I want to calculate IRRs for.
I set it all up pretty lean:
use ".\dta\xxx.dta"
keep id survivaltime_m id funded_amnt int_rate installment
gen a0 = -1*funded_amnt
local i
forvalues i =1(1)60{
gen a`i'=0
replace a`i'=installment if `i'<= survivaltime_m
}
reshape long a, i(id) j(time)
tsset id time
So far it is fine. Now I am trying to loop over all the IDs of the
loans to calculate the IRR.
gen save = 0
local i
foreach i in `id' {
finirr a if id == `i'
replace save = r(irr) if id == `i'
}
This simply does not work. The Loop runs without any error message.
However, no results are saved in save.
I did my homework and tried several alternatives:
levelsof id, local(ids)
foreach i of local ids {
finirr a if id == `i'
replace save = r(irr) if id == `i'
}
egen group = group(id)
su group, meanonly
foreach i of num 1/2{
finirr a if id == `i'
replace save = r(irr) if id == `i'
}
NOTHING works ! :-(
Any help would be warmly appreciated !
Win 7 - 64bit
Stata 12.1 SE
12GB RAM / i5 - maschine
Dear All,
I have a set 245.000 loans I want to calculate IRRs for.
I set it all up pretty lean:
use ".\dta\xxx.dta"
keep id survivaltime_m id funded_amnt int_rate installment
gen a0 = -1*funded_amnt
local i
forvalues i =1(1)60{
gen a`i'=0
replace a`i'=installment if `i'<= survivaltime_m
}
reshape long a, i(id) j(time)
tsset id time
So far it is fine. Now I am trying to loop over all the IDs of the
loans to calculate the IRR.
gen save = 0
local i
foreach i in `id' {
finirr a if id == `i'
replace save = r(irr) if id == `i'
}
This simply does not work. The Loop runs without any error message.
However, no results are saved in save.
I did my homework and tried several alternatives:
levelsof id, local(ids)
foreach i of local ids {
finirr a if id == `i'
replace save = r(irr) if id == `i'
}
egen group = group(id)
su group, meanonly
foreach i of num 1/2{
finirr a if id == `i'
replace save = r(irr) if id == `i'
}
NOTHING works ! :-(
Any help would be warmly appreciated !
Comment