I have a dataset with about 50,000 observations. Each observation corresponds to a loan's information. I'm using the -payper- command to generate the amortization schedule for each loan. The -payper- command generates that in a matrix which I would need to save. I have written the following code segment.
Code:
local n = _N
forvalues i = 1/`n' {
use tmp, replace
local pv = PRINCIPLE_LC_AMOUNT in `i'
local nper = NUMBER in `i'
local profit_rate = PROFIT_RATE in `i'
local deal = DEAL_NO1 in `i'
payper, pv(`pv') nper(`nper') freq(m) rate(`profit_rate')
mat B`i' = J(`nper',1,`deal')
mat A = r(matpay),B`i'
drop _all
svmat A, n(col)
save "Individual\pay`i'", replace }
The code works fine and accomplishes the desired outcome. However, it takes a long time to loop over all of the observations. Is there a better and more efficient way to achieve the same result? Thanks for your help.
0 Response to Using PAYPER to generate amortization tables
Post a Comment