Hello, I am looping correlation coefficients over hundreds of variables, and am dumping outputs and variable names of the coefficient correlations into a new dta file. When trace is on, I see Stata seems to all the inputs needed to put into the new dta, but it returns function error. Below is the code, and what Stata returns to me. I've tinkered around with changing orders of the variables, it's always variable 6 that seems to catch the code.

I've seen some help on other threads, but they don't seem to fix this one.

set trace on

tempname trial
postfile `trial' coef lb up samp str20 var1 str80 varlab str20 var2 str80 valab2 using "pointbiserial.dta", replace
quietly{
local i=0
foreach var of varlist re_* {
foreach var2 of varlist pol_* {
local i=`i'+1
noisily: di "`i'" "-" "`var'" "-" "`var2'"

capture esize unp `var'==`var2', pbcorr
return list

post `trial4' (`r(r_pb)') (`r(lb_r_pb)') (`r(ub_r_pb)') (`r(N_1)') ("`var'") ("`: var lab `var''")("`var2'")("`: var label `var2''")

}
}
}
postclose `trial'
Stata returns: seems to correctly get all inputs

- return list
- post `trial4' (`r(r_pb)') (`r(lb_r_pb)') (`r(ub_
> r_pb)') (`r(N_1)') ("`var'") ("`: var lab `var''
> ")("`var2'")("`: var label `var2''")
= post __000000 (.362545436385054) (.3450367943898
> 245) (.3796625592485258) (4370) ("re_1_1_1_yr")
> ("1.1.1: Does a legal framework for renewable en
> ergy development exist?")("pol_flag")("polity_te
> ntative coding (p4)")
unknown function ()
post: above message corresponds to expression 6,
> variable varlab

}
}