0 2 4
-1 0 1
-2 -1 0
i wanna generate all data t`i'*w[_n] but minus one would multiple with var ww not w,so i use code like this
Code:
gen BP=0 forvalues i=1(1)3 { if t`i'>=0{ gen a=t`i'*w[_n] if t`i'>=0 egen a2=total(a) replace BP=a2 if code==`i' drop a a2 } else{ if `i'<=3{ local j=`i'+1 local i=`j' } } }
Code:
gen BN=0 forvalues i=2(1)3 { if t`i'<=0{ gen a=t`i'*ww[_n] if t`i'<=0 egen a2=total(a) replace BP=a2 if code==`i' drop a a2 } else{ if `i'<=3{ local j=`i'+1 local i=`j' } }
0 Response to Why the similar code leads to opposite result
Post a Comment