I am trying to learn Stata's -collect- and to manipulate tables. I find the manipulating part hard.


What I did it with six:

Code:
collect clear
* add custom results has_year_fe and has_panel
collect _r_b _r_se has_year_fe="NO" has_panel="NO", tag(model[(1)]): reg d.ln_co2pc l.co2pc d.ln_gdppc d.URB, r
collect _r_b _r_se has_year_fe="NO" has_panel="SI", tag(model[(2)]): xtreg d.ln_co2pc l.co2pc d.ln_gdppc d.URB,fe r
collect _r_b _r_se has_year_fe="SI" has_panel="SI", tag(model[(3)]): xtreg d.ln_co2pc l.co2pc d.ln_gdppc d.URB i.year,fe r
collect _r_b _r_se has_year_fe="SI" has_panel="SI", tag(model[(4)]): xtreg d.ln_co2pc l.co2pc d.ln_gdppc d.URB d.ei i.year,fe r
collect _r_b _r_se has_year_fe="SI" has_panel="SI", tag(model[(5)]): xtreg d.ln_co2pc l.co2pc d.ln_gdppc d.URB d.res_share i.year,fe r
collect _r_b _r_se has_year_fe="SI" has_panel="SI", tag(model[(6)]): xtreg d.ln_co2pc l.co2pc d.ln_gdppc d.URB d.ei d.res_share i.year,fe r
collect layout (colname#result) (model)
collect style showbase off
collect style cell, nformat(%5.2f) border(right, pattern(nil))
collect style cell result[_r_se], sformat("(%s)")
collect preview
collect style cell cell_type[item column-header], halign(center)
collect style header result, level(hide)
collect style column, extraspace(1)
collect stars _r_p 0.01 "***" 0.05 "** " 0.1 "*  " 1 "   ", attach(_r_b) 
* modify layout to accommodate our custom results and suppress the i.year results
collect layout (colname[d.ln_co2pc l.co2pc d.ln_gdppc d.URB d.ei##d.res_share]#result[_r_b _r_se] result[has_year_fe has_panel r2 N]) (model)
* show label of our custom results in the header
collect style header result[has_year_fe has_panel r2 N], level(label)
collect style header colname, level(value)
collect style row stack, spacer delimiter(" x ")
* label our custom result levels
collect label levels result has_year_fe "Efectos fijos año" has_panel "Efectos fijos país" N "N" r2 "R2", modify
collect style cell result[N], nformat(%5.0f)
collect preview

-----------------------------------------------------------------------------------
                       (1)        (2)        (3)        (4)        (5)        (6)  
-----------------------------------------------------------------------------------
L.co2pc             -0.00*     -0.00      -0.00      -0.00      -0.00      -0.00   
                     (0.00)     (0.00)     (0.00)     (0.00)     (0.00)     (0.00) 
                                                                                   
D.ln_gdppc           1.06***    1.08***    1.06***    1.10***    0.83***    0.87***
                     (0.11)     (0.16)     (0.21)     (0.20)     (0.15)     (0.15) 
                                                                                   
D.URB                0.00***    0.00***    0.00**     0.00**     0.00*      0.00*  
                     (0.00)     (0.00)     (0.00)     (0.00)     (0.00)     (0.00) 
                                                                                   
D.ei                                                  0.07***               0.08***
                                                      (0.02)                (0.03) 
                                                                                   
D.res_share                                                     -0.02***   -0.02***
                                                                 (0.00)     (0.00) 
                                                                                   
Efectos fijos año      NO         NO         SI         SI         SI         SI   
                                                                                   
Efectos fijos país     NO         SI         SI         SI         SI         SI   
                                                                                   
R2                    0.21       0.21       0.27       0.28       0.44       0.44  
                                                                                   
N                     1100       1100       1100       1100       1089       1089  
-----------------------------------------------------------------------------------
I would like to change columns' names:
Code:
---------------------------------------------------------------------------------------------------
                                   Tasa crecimiento emisiones CO2 pc
                        ---------------------------------------------------------------
                        Modelo 1   Modelo 2   Modelo 3   Modelo 4   Modelo 5   Modelo 6
---------------------------------------------------------------------------------------------------
Emision CO2pc período anterior      -0.00*     -0.00      -0.00      -0.00      -0.00      -0.00   
                                 (0.00)     (0.00)     (0.00)     (0.00)     (0.00)     (0.00) 
                                                                                   
Tasa crecimiento PIB pc            1.06***    1.08***    1.06***    1.10***    0.83***    0.87***
                                   (0.11)     (0.16)     (0.21)     (0.20)     (0.15)     (0.15) 
                                                                                   
Variación Urbanismo               0.00***    0.00***    0.00**     0.00**     0.00*      0.00*  
                                 (0.00)     (0.00)     (0.00)     (0.00)     (0.00)     (0.00) 
                                                                                   
Variación Intensidad Energética                            0.07***               0.08***
                                                           (0.02)                (0.03) 
                                                                                   
Variación Participación ER                                                      -0.02***   -0.02***
                                                                                 (0.00)     (0.00) 
                                                                                   
Efectos fijos año                  NO         NO         SI         SI         SI         SI   
                                                                                   
Efectos fijos país                NO         SI         SI         SI         SI         SI   
                                                                                   
R2                                0.21       0.21       0.27       0.28       0.44       0.44  
                                                                                   
Número de observaciones            1100       1100       1100       1100       1089       1089  
------------------------------------------------------------------------------------------------------
And to use continuos line but I don't know how to do it.

Can someone help me?

Regards,

Sebastian.