Dear statalist
i have a sample of only 3 observation, i having problem calculating outer product of the gradient , the gradient and updating formula using forvalues loop and postfile command, i get an error message "post sim not found" another question could i use a variable or macro to hold the opg, gr and theta instead of scalar, any help would be greatly appreciated , my do file is as follows

clear all
set obs 100
input y
3.5
1
1.5
end
sca theta1 =1
gen f = -1/theta1 + y/theta1^2
tempname sim
tempfile result
postfile `sim' opg gr theta using result, replace
forvalues i=1/100 {
qui {
sca opg`i' = 1/3*(-1/theta`i' + y[1]/theta`i'^2 )^2 + 1/3*(-1/theta`i' + y[2]/theta`i'^2)^2+ 1/3*(-1/theta`i' + y[3]/theta`i'^2)^2 /* calculating OPG for every iteration*/

sca gr`i' = 1/3*(-1/theta`i' + y[1]/theta`i'^2 ) + 1/3*(-1/theta`i' + y[2]/theta`i'^2)+ 1/3*(-1/theta`i' + y[3]/theta`i'^2) /* calculating the gradient at every iteration*/
loc j=`i'+1
sca theta`j' = theta`i' + (opg`i')^-1*gr`i' /* updating formula*/
post sim (opg`i') (gr`i') (theta`j')
}
}
postclose `sim'
use result, clear
i get error message!!!
post sim not found
r(111);

end of do-file

r(111);