Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str6 date long bns float bns_qrt_growth long(cbna fcib fgb) "Mar-14" 176535310 . 11294717 35831053 22359818 "Jun-14" 190726980 8.04 10644840 35897166 23619625 "Sep-14" 192644381 1.01 9901093 37192064 23526022 "Dec-14" 194210805 .81 10754557 38620165 24288135 "Mar-15" 186943115 -3.74 9774468 40428726 25382380 "Jun-15" 198691679 6.28 13190912 43019852 26311049 "Sep-15" 214435176 7.92 13174967 44976924 26726495 "Dec-15" 212618211 -.85 13804100 50453410 26766775 "Mar-16" 220099378 3.52 12126162 54608312 29789672 "Jun-16" 244633857 11.15 11136283 51588411 32222677 "Sep-16" 237884451 -2.76 13277994 52869157 33116516 "Dec-16" 239354182 .62 13204974 51947427 33396243 "Mar-17" 243451013 1.71 12286569 54768652 32397767 "Jun-17" 258912892 6.35 14068066 58157548 35323039 "Sep-17" 262534320 1.4 15126217 58218143 39123263 "Dec-17" 259433254 -1.18 15284789 58249010 35861926 end
Code:
local banks cbna fcib fgb local i = 1 foreach f of local banks { gen var`i' `f'_qrt_growth = (f - f[_n-1])*100/f[_n-1] local ++i
The second problem is, after calculating the quarterly growth rates, I want to divide these growth rates by 3 and then extrapolate monthly values for bns. For example, for June 2014, the bns growth rate is 8.04 which divided by 3 is 2.68. Now, for April 2014, the bns will be calculated as 176535310*(1+.0268).
If anybody could give some idea about how to go about it, that would be highly appreciated. I hope I am not asking for too much. Thanks.
0 Response to Use for loop to generate growth rate and extrapolate data
Post a Comment