In the following dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input double(grid coeff1) float(grid_1 grid_2 grid_3 f0) .4486396262520715 .0005256978029485812 .4486396 .2012775 .09030107 0 .44865590670032207 -.0008528920278404954 .4486559 .20129213 .0903109 0 .44867218714857265 .0003351585090252788 .4486722 .20130673 .09032073 0 .4486884675968232 .00012919439508951027 .4486885 .20132133 .09033056 0 .44870474804507376 . .44870475 .20133595 .0903404 0 .44872102849332435 . .448721 .20135055 .09035023 0 .44873730894157493 . .4487373 .20136517 .09036007 0 .4487535893898255 . .4487536 .2013798 .0903699 0 .44876986983807604 . .4487699 .2013944 .09037974 0 .4487861502863266 . .4487861 .201409 .09038957 0 .4488024307345772 . .4488024 .2014236 .09039941 0 .4488187111828278 . .4488187 .20143823 .09040925 0 end
My attempt at this is the following:
Code:
summ grid local N1 = r(N) di `N1' summ coeff1 local N2 = r(N) di `N2'-1 forvalues k = 1/`N1' { forvalues q = 1/(`N2'-1) { replace f0 = f0[`k'] + coeff1[`q'] * grid_`q'[`k'] in `k' } replace f0 = f0[`k'] + coeff1[`N2'] in `k' }
0 Response to Replace values in each row
Post a Comment