Dear Ben Jann,

I am very much thankful for all the scripts and packages that you have written so far and all the possibilities that result from these powerful tools!! Usually I have found a workaround or solution for possible problems and applications, however this time I am running out of ideas.

I hope you (or Andrew Musau or Nils Enevoldsen f.e.) will find some time to give me a proper hint to solve the following problem. The following code (see first code chunk) produces redundant table beginnings, when looping and appending regression results with esttab. (&\multicolumn{})
Almost the same code (see second code chunk) creates summary statistics over a couple of variables for different birth cohorts separately, which works absolutely fine for the tabstat command.

My guess is, that it is because the tabstat results end up in one matrix per covariate, whereas the weighted ttests calculated with bivariate regression results produce one matrix for each category of every variable of interest.This seemingly results in redundant table openings:
&\multicolumn{1}{c}{pov\_ynhhinc\_new\_p50}&\multi column{1}{c}{pov\_ynhhinc\_new\_p50}\\
where I would expect a simple \addlinespace. This crashes the whole routine and table. None of the options to suppress these issues or ideas in forums could solve the problem so far.
Array

Fixed by hand, the outcome of desire would look like this: Array

The problematic code:

Code:
    /* Zeit (Makro) – T-Test (Differenz Kohorte 1950-59 mit 1970-80)             */
    foreach cut in p50 mean {
        foreach var of global time {
          foreach num of numlist 0 {
        
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
            local diff "{$\Delta$}: (1970er) -- (1950er)"
        
        
        * Einheimische:
        reg pov_ynhhinc_new_`cut' i.cohort [aweight=phrfe] ///
        if mig==0 & `var'==`num' & cohort!=1
        est store a_pom_`cut'_`var'_`num'
        
        * Zugewanderte:
        reg pov_ynhhinc_new_`cut' i.cohort [aweight=phrfe] ///
        if mig==1 & `var'==`num' & cohort!=1
        est store a_pmm_`cut'_`var'_`num'
        
        
        * Header : a
        esttab a_pom_`cut'_`var'_`num' a_pmm_`cut'_`var'_`num' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a3.tex", append ///
         mgroups("\multicolumn{2}{c}{`diff'}") ///
            mtitles("\textbf{\emph{PoM}}" "\textbf{\emph{PmM}}") ///
                 prehead("\textbf{Zeiträume}") ///
                    refcat("2.cohort" "\emph{`l_`var''}", nolabel) ///
        collabels(none) alignment(S) b(a1) star(* 0.05 ** 0.01 *** 0.001)  ///
        wide booktabs fragment gaps compress transform(@*100) ///
        nonote noobs nonumber nolines not drop(0.cohort* _cons*)
        
        * Header : b
        esttab a_pom_`cut'_`var'_`num' a_pmm_`cut'_`var'_`num' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-b3.tex", append ///
         mgroups("\multicolumn{2}{c}{`diff'}") ///
            mtitles("\textbf{\emph{PoM}}" "\textbf{\emph{PmM}}") ///
                 prehead("\textbf{Zeiträume}") ///
                    refcat("2.cohort" "\emph{`l_`var''}", nolabel) ///
        collabels(none) alignment(S) b(a1) star(* 0.05 ** 0.01 *** 0.001)  ///
        wide booktabs fragment gaps compress transform(@*100) ///
        nonote noobs nonumber nolines not drop(0.cohort* _cons*)
            }
        }
    }
    
    * - - - - - - - - - - - - - - - - - *
    
    foreach cut in p50 mean {
        foreach var of global time {
          foreach num of numlist 1/5 {
        
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var' if `var'== `num'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
            local diff "{$\Delta$}: (1970er) -- (1950er)"
        
        
        * Einheimische:
        reg pov_ynhhinc_new_`cut' i.cohort [aweight=phrfe] ///
        if mig==0 & `var'==`num' & cohort!=1
        est store a_pom_`cut'_`var'_`num'
        
        * Zugewanderte:
        reg pov_ynhhinc_new_`cut' i.cohort [aweight=phrfe] ///
        if mig==1 & `var'==`num' & cohort!=1
        est store a_pmm_`cut'_`var'_`num'
                    
                    
        * Header : a
        esttab a_pom_`cut'_`var'_`num' a_pmm_`cut'_`var'_`num' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a3.tex", append ///
        collabels(none) alignment(S) b(a1) star(* 0.05 ** 0.01 *** 0.001)  ///
        wide booktabs fragment compress transform(@*100) ///
        nonote noobs nonumber nolines not keep(2.cohort*)
        
        * Header : b
        esttab a_pom_`cut'_`var'_`num' a_pmm_`cut'_`var'_`num' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-b3.tex", append ///
        collabels(none) alignment(S) b(a1) star(* 0.05 ** 0.01 *** 0.001)  ///
        wide booktabs fragment compress transform(@*100) ///
        nonote noobs nonumber nolines not keep(2.cohort*) 
        
            }
        }
    }




My source code:

Code:
/*    D E S K R I P T I O N: Gesamt (1) – über alle Zeitpunkte -vs- Alterskohorten (2)
                                      – über alle Zeitpunkte -vs- Geburtskohorten (3) */
    global time      syear_cat 
    global microI     age_cat
    global micro     gender edu_cat emplstat egp_last /* isei */ subj_health
    global mesoI      famstat
    global meso      kidshh_cat housing 
    global macroI     eastwest
    global macro     loc1989 fed_state muncip econ_sector
        
    * ––––––––––––––––– *
    *  (1) G E S A M T  *
    * ––––––––––––––––– *
               
    // (1) Gesamt: Alle in Deutschland lebenden Personen im erwerbsfähigen Alter
    foreach let in a b c {
    cap erase "${LOG_PATH}/00-table-pov-p50-`let'.tex"
    cap erase "${LOG_PATH}/00-table-pov-mean-`let'.tex"
    }
    
    eststo clear
    estimates clear
    
    
    /* Zeit (Makro) */
    foreach cut in p50 mean {
        foreach var of global time {
    estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe], ///
    by(`var') statistics(mean) columns(statistics) nototal
    est store a_ges_`cut'_`var'
    estadd matrix pc = e(mean)*100
    
        * Extract first value label as identifier (refcat)
        levelsof `var', local(levels)
        local lbe : value label `var'
        
        foreach l of local levels {
            local f`l' : label `lbe' `l'
        }
        di "`f0'"
        
        * Extract variable label for (refcat)
        qui fre `var'
        local l_`var' = "`r(label)'"
        *local l_`var' = "`e(labels)'"
        disp in red "`l_`var''"
        
        * Header : a
        esttab a_ges_`cut'_`var' ///
        using "${LOG_PATH}/00-table-pov-`cut'-a.tex", append ///
         mgroups(" ") ///
         mtitles("{\normalsize\textbf{$\diameter$}}") ///
            prehead("\textbf{Zeiträume}") ///
                refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
        
        * Header : b
        esttab a_ges_`cut'_`var' ///
        using "${LOG_PATH}/00-table-pov-`cut'-b.tex", append ///
         mgroups(" ") ///
         mtitles("{\normalsize\textbf{$\diameter$}}") ///
            prehead("\textbf{Zeiträume}") ///
                refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }

    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *
    
    /* Individualmerkmale (MikroI) */
    foreach cut in p50 mean {
        foreach var of global microI {
    estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe], ///
    by(`var') statistics(mean) columns(statistics) nototal
    est store a_ges_`cut'_`var'
    estadd matrix pc = e(mean)*100
    
        * Extract first value label as identifier (refcat)
        levelsof `var', local(levels)
        local lbe : value label `var'
        
        foreach l of local levels {
            local f`l' : label `lbe' `l'
        }
        di "`f0'"
        
        * Extract variable label for (refcat)
        qui fre `var'
        local l_`var' = "`r(label)'"
        *local l_`var' = "`e(labels)'"
        disp in red "`l_`var''"
        
        esttab a_ges_`cut'_`var' ///
        using "${LOG_PATH}/00-table-pov-`cut'-a.tex", append ///
            prehead(\\ \bottomrule \addlinespace "\textbf{Individualmerkmale}") ///
                refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }    
    
    /* Individualmerkmale (Mikro) */
    foreach cut in p50 mean {
        foreach var of global micro {
    estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe], ///
    by(`var') statistics(mean) columns(statistics) nototal
    est store a_ges_`cut'_`var'
    estadd matrix pc = e(mean)*100
    
        * Extract first value label as identifier (refcat)
        levelsof `var', local(levels)
        local lbe : value label `var'
        
        foreach l of local levels {
            local f`l' : label `lbe' `l'
        }
        di "`f0'"
        
        * Extract variable label for (refcat)
        qui fre `var'
        local l_`var' = "`r(label)'"
        *local l_`var' = "`e(labels)'"
        disp in red "`l_`var''"
        
        esttab a_ges_`cut'_`var' ///
        using "${LOG_PATH}/00-table-pov-`cut'-a.tex", append ///
            refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        eststo clear
        estimates clear
        }    
    
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *


*------------------------------------------------------------------------------*
*------------------------------------------------------------------------------*


    * ––––––––––––––––––––––––––––––----- *
    *  (3) G E B U R T S K O H O R T E N  *
    * –––––––––––––––––––––––––––––––---- *
    global time      syear_cat 
    global microI     age_cat
    global micro     gender edu_cat emplstat egp_last isei subj_health
    global mesoI      famstat
    global meso      kidshh_cat housing 
    global macroI     eastwest
    global macro     loc1989 fed_state muncip econ_sector

                 
    // (2) Spezifisch: Einheimische -vs- Zugewanderte nach Geburtskohorten
    foreach let in a b c {
        foreach coh of numlist 0/3 {
    cap erase "${LOG_PATH}/00-table-pov-bycoh-p50-`let'`coh'.tex"
    cap erase "${LOG_PATH}/00-table-pov-bycoh-p50-`let'`coh'.tex"
    cap erase "${LOG_PATH}/00-table-pov-bycoh-mean-`let'`coh'.tex"
    cap erase "${LOG_PATH}/00-table-pov-bycoh-mean-`let'`coh'.tex"
    eststo clear
        }
    }
    
    /* Zeit (Makro) – 1. Spalte Tabelle (Kohorte mit Value labels) */
    foreach coh of numlist 0 {
    foreach cut in p50 mean {
        foreach var of global time {
            
        
        * Einheimische:
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==0 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pom_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100

        
        * Zugewanderte (Gesamt):
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==1 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pmm_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100
        
    
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
        
        * Header : a
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a`coh'.tex", append ///
         mgroups("\multicolumn{2}{c}{`a`coh''}") ///
            mtitles("\textbf{\emph{PoM}}" "\textbf{\emph{PmM}}") ///
                 prehead("\textbf{Zeiträume}") ///
                  refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
        
        * Header : b
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-b`coh'.tex", append ///
         mgroups("\multicolumn{2}{c}{`a`coh''}") ///
            mtitles("\textbf{\emph{PoM}}" "\textbf{\emph{PmM}}") ///
                 prehead("\textbf{Zeiträume}") ///
                  refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }
    }
    
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *

    /* Zeit (Makro) – X. Spalte Tabelle (Kohorte OHNE Value labels) */
    foreach coh of numlist 1/2 {
    foreach cut in p50 mean {
        foreach var of global time {
            
        
        * Einheimische:
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==0 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pom_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100
        
        * Zugewanderte (Gesamt):
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==1 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pmm_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100

    
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
        
        * Header : a
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a`coh'.tex", append ///
         mgroups("\multicolumn{2}{c}{`a`coh''}") ///
            mtitles("\textbf{\emph{PoM}}" "\textbf{\emph{PmM}}") ///
                 prehead("\textbf{Zeiträume}") ///
                  refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        wide booktabs fragment nonote noobs nonumber gaps compress nolines
        
        * Header : b
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-b`coh'.tex", append ///
         mgroups("\multicolumn{2}{c}{`a`coh''}") ///
            mtitles("\textbf{\emph{PoM}}" "\textbf{\emph{PmM}}") ///
                 prehead("\textbf{Zeiträume}") ///
                  refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }
    }
    
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *
    
    
    
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *

    // I N D I V I D U A L (Mikro) : nach Geburtskohorten
    
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *
    
    /* Individualmerkmale (MikroI) – 1. Spalte Tabelle (Kohorte mit Value labels) */
    foreach coh of numlist 0 {
    foreach cut in p50 mean {
        foreach var of global microI {
            
        
        * Einheimische:
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==0 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pom_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100
        
        * Zugewanderte (Gesamt):
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==1 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pmm_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100

    
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
        
        
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a`coh'.tex", append ///
            prehead(\\ \bottomrule \addlinespace "\textbf{Individualmerkmale}") ///
                refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }
    }
    
    /* Individualmerkmale (Mikro) – 1. Spalte Tabelle (Kohorte mit Value labels) */
    foreach coh of numlist 0 {
    foreach cut in p50 mean {
        foreach var of global micro {
            
        
        * Einheimische:
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==0 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pom_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100
        
        * Zugewanderte (Gesamt):
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==1 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pmm_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100

    
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
        
        
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a`coh'.tex", append ///
                  refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }
    }
    
    * - - - - - - - - - - - - - - - - -  - - - - - - - - - - - - - - - - - - - - - *

    /* Individualmerkmale (MikroI) – X. Spalte Tabelle (Kohorte OHNE Value labels) */
    foreach coh of numlist 1/2 {
    foreach cut in p50 mean {
        foreach var of global microI {
            
        
        * Einheimische:
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==0 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pom_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100
        
        * Zugewanderte (Gesamt):
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==1 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pmm_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100

    
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
        
        
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a`coh'.tex", append ///
            prehead(\\ \bottomrule \addlinespace "\textbf{Individualmerkmale}") ///
                refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        label wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }
    }
    
    /* Individualmerkmale (Mikro) – X. Spalte Tabelle (Kohorte OHNE Value labels) */
    foreach coh of numlist 1/2 {
    foreach cut in p50 mean {
        foreach var of global micro {
            
        
        * Einheimische:
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==0 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pom_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100
        
        * Zugewanderte (Gesamt):
        estpost tabstat pov_ynhhinc_new_`cut' [aweight=phrfe] ///
        if mig==1 & cohort==`coh', ///
        by(`var') statistics(mean) columns(statistics) nototal
        est store a_pmm_`cut'_`var'_`coh'
        estadd matrix pc = e(mean)*100

    
            * Extract first value label as identifier (refcat)
            levelsof `var', local(levels)
            local lbe : value label `var'
            
            foreach l of local levels {
                local f`l' : label `lbe' `l'
            }
            di "`f0'"
            
            * Extract variable label for (refcat)
            qui fre `var'
            local l_`var' = "`r(label)'"
            *local l_`var' = "`e(labels)'"
            disp in red "`l_`var''"
            
            * Extract value label for title
            levelsof cohort, local(levels)
            local lba : value label cohort
            
            foreach l of local levels {
                local a`l' : label `lba' `l'
            }
            di "`a`coh''"
        
        
        esttab a_pom_`cut'_`var'_`coh' a_pmm_`cut'_`var'_`coh' ///
        using "${LOG_PATH}/00-table-pov-bycoh-`cut'-a`coh'.tex", append ///
                  refcat("`f0'" "\emph{`l_`var''}", nolabel) ///
                    collabels(none) cells("pc(fmt(1))") alignment(S)  ///
        wide booktabs fragment nonote noobs nonumber gaps compress nolines
            }
        }
    }