I am trying to save output tex files in a specific directory after running a batch of regressions.

Code:
global textablespath "C:\Users\bxerxes\Dropbox\Research\selfemp\dofiles\textables"

foreach var in patience trust{
reghdfe selfemp `var'_fe if ssg==1, a(styr) cluster(ctrycode)
est store a
reghdfe selfemp `var'_fe  $cont if ssg==1, a(styr) cluster(ctrycode)
est store b
reghdfe selfemp `var'_fe  $geog if ssg==1, a(styr) cluster(ctrycode)
est store c
reghdfe selfemp `var'_fe $relig  if ssg==1, a(styr) cluster(ctrycode)
est store d
reghdfe selfemp `var'_fe  $cps2 if ssg==1, a(styr) cluster(ctrycode)
est store e
reghdfe selfemp `var'_fe  $cps2 $geog $cont $relig if ssg==1, a(styr) cluster(ctrycode)
est store f
esttab a b c d e f  using "$textablespath\`var'_appendixtable.tex", replace b(%10.3f) se scalars(N ar2) mtitles keep(`var'_fe) label star(* .1 ** .05 *** .01)
eststo clear
}
Unfortunately, the results are saved at diffeent location and ignores the local macro `var':

Code:
(output written to C:\Users\bxerxes\Dropbox\Research\selfemp\dofiles\textables_appendixtable.tex)