Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • To change coefficent order to what I want

    Hello.
    When I make several results on one excel sheet, is it possible to locate sepcific variables in order of what I wanna set.
    For example, in this case, I hope the red hollow circle part(the four variables) can be located on the 'male' varaible to make the table more clean.
    Behind one is my codes.


    global var dadedu_somecol dadedu_col dadeducol_age14region_noncapital
    local age 30,59

    *foreach fit in lin quad { _`fit
    foreach sx in all male female {
    foreach var in $var {
    foreach i of numlist 10 15 {

    * (1) i.age14region
    reg edu_somecol `var'##post ${`fit'} $ctrl1 if inrange(cbirthyr,-`i',`i') ${`sx'} & inrange(age,`age'), vce (cluster cl_group)
    estadd ysumm, mean

    if "`var'"=="dadedu_somecol" & `i'==10 {
    local how replace
    }
    else {
    local how append
    }

    est save ${rslt}/collapse/bandwidth`i'/`var'_c1', replace //1 all 2 male 3 female
    outreg2 using ${tab}/collapse/`sx', `how' dta dec(3) adjr2 ///
    cttop("band`i'") adds("Dep. var. mean", e(ymean), "Adjusted R-squared", e(r2_a)) adec(3) ///
    keep(1.`var' 1.post 1.`var'#1.post)

    * (2) i.age14region age age_sq
    reg edu_somecol `var'##post ${`fit'} $ctrl2 if inrange(cbirthyr,-`i',`i') ${`sx'} & inrange(age,`age'), vce (cluster cl_group)
    estadd ysumm, mean

    est save ${rslt}/collapse/bandwidth`i'/`var'_c2, replace //1 all 2 male 3 female
    outreg2 using ${tab}/collapse/`sx', append dta dec(3) adjr2 ///
    cttop("band`i'") adds("Dep. var. mean", e(ymean), "Adjusted R-squared", e(r2_a)) adec(3) ///
    keep(1.`var' 1.post 1.`var'#1.post male age age_sq nsib)
    }

    }
    }
    *}

    Attached Files

  • #2
    You can use "sortvar" option in outreg2 to do so.
    Here's an example.

    Code:
    sysuse auto, clear
    reg    price    mpg    weight c.length##c.foreign
    
    outreg2 using myfile.txt,  replace
    outreg2    using myfile.txt, sortvar(c.length#c.foreign weight) // change order
    More information on outreg2 manual

    Code:
    help outreg2##s_8

    Comment

    Working...
    X