outreg2, spaces in the file name have unrecognizable conditions in stata

0

I have a regression loop in the data panel, what I do is separate by sector with the "levelsoft" command

levelsof sector, local(a)  

what generates the next result

'"Animal"' '"Chemicals"' '"Food Products"' '"Fuels"' '"Mach and Elec"' '"Metals"' '"Miscellaneous"' '"Plastic or Rubber"' '"Stone and Glass"' '"Transportation"' '"Vegetable"'

then for each sector I do an intra-sector pool type regression

foreach x of local a{
    preserve
    keep if sector =="'x'"
    collapse code_partner dPIB m Comercio_PIB Inflacion i PIBpc TC dist tariff tratado q,by(sector tariffyear partneriso3 )
    xtset $id $t
    *todo
    display "****************************************************************** 'x'"
    reg $ylist $xlist_tq dist
    outreg2 using Estimacion_NTBs_SubPool_'x'.txt, replace text dec(4)
    *sin t
    display "****************************************************************** 'x'"
    reg $ylist $xlist_nt dist
        outreg2 using Estimacion_NTBs_SubPool_'x'.txt, append text dec(4)
    *sin q
    display "****************************************************************** 'x'"
    reg $ylist $xlist_nq dist
    outreg2 using Estimacion_NTBs_SubPool_'x'.txt, append text dec(4)
    restore
}

The problem is that some of the observations of the local x (generated with leversoft) have a space "Food Products" and at the time of running the command outreg2 it understands only one of the words as the name and the second part as a unrecognizable command.

I need to Export each of the estimates of this loop to excel, if there is a solution to this problem or another more efficient way I would like to know it

    
asked by Andres Felipe Estrada Rodrigue 04.12.2018 в 19:46
source

0 answers