Hi Stata users,
I am using Stata 17 with the data below
and the syntax below
which produces two separate files. However, I am interested in having the 2 regressions in the same table as shown below
I am using Stata 17 with the data below
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte(id treat_1 treat_2) float(inc1 inc2 inc3 inc4 inc5) 1 0 1 .7976204 4.1942024 5.245255 .10473073 1.074206 2 0 0 .47407645 3.792366 .3411162 .3846039 .8841304 3 0 1 .6531336 3.224448 -1.7688324 .6093524 .77727 4 1 1 .3032387 2.1221611 1.6901972 .2616425 1.3166127 5 0 1 .2589492 2.9983294 2.891384 .4783743 1.3495697 6 0 0 .5340883 3.701502 5.076627 .3636863 1.3437552 7 1 1 .9946184 1.0632204 -.51245594 .396791 1.0182812 8 0 1 .2055029 3.343932 2.0526712 .39188385 .8750828 9 0 1 .1469368 1.2287648 -1.0609996 .10763865 1.1927526 10 1 0 .7248068 2.615765 3.4659834 .535525 1.0636038 11 0 1 .4614167 2.1932366 -.55151784 .11801913 1.1967903 12 0 0 .49889645 2.9786394 -2.434414 .3204233 .8190476 13 0 1 .7752892 2.482335 5.213848 .19369332 1.0469966 14 1 1 .12218582 3.469138 -3.822111 .3849409 1.2151845 15 0 0 .014872712 4.5568743 3.355275 .59117293 1.3707263 16 0 1 .4145085 4.2914343 1.2265193 .2451194 1.0645933 17 0 1 .007562647 3.3815956 1.5634396 .54290044 1.2678412 18 1 0 .7713944 3.654437 .18936282 .12094904 1.3673985 19 0 1 .7528632 1.867146 2.1884887 .6213306 1.3114703 20 0 0 .03606825 3.6839476 8.151359 .5972792 .9351298 21 0 0 .6612601 2.2957428 1.5307722 .3679009 1.0185285 22 1 0 .7942301 1.0496974 4.402489 .3046494 1.3344676 23 0 1 .8157656 3.08776 -.8101026 .3597128 .9886929 24 1 0 .3827037 1.619985 -2.195996 .4166688 1.3541038 25 0 0 .1142242 3.145981 8.385159 .627951 .8852876 26 1 1 .6967155 3.253544 1.756245 .5432824 1.3377906 27 1 0 .58090734 3.547663 -.7702299 .54652625 .9399282 28 1 1 .7513731 2.4031036 1.0336325 .5269326 1.1186568 29 0 1 .07328983 2.860274 9.014268 .54757184 .9556946 30 0 1 .5983487 4.5375338 .9830748 .4824094 1.1291447 31 1 0 .8813461 4.3399262 1.295104 .004048215 1.269165 32 1 0 .7424953 2.433257 2.984678 .5368601 1.0595611 33 1 1 .1727252 1.9523844 .57852733 .3706819 1.043798 34 1 1 .21490055 4.2096415 3.457928 .18649752 1.1474588 35 0 1 .08933518 1.7212585 -1.246071 .02256559 .9247364 36 0 0 .7930722 3.461499 3.248368 .28555918 1.3566847 37 1 0 .7631631 2.533106 -1.65908 .43283305 1.3582025 38 0 0 .6169553 1.8988973 -.2454512 .51791817 1.3399636 39 0 0 .2515084 3.886478 -1.8298178 .22266237 1.081383 40 0 1 .12948492 1.7549975 1.7591347 .42210105 1.31896 41 0 0 .9221812 3.1141884 8.276983 .4994179 1.0405848 42 1 1 .00051179 2.651729 1.0294415 .4408414 .8307965 43 1 0 .8352846 .8142371 7.046671 .402408 1.1768478 44 0 0 .24707566 1.9979717 -.7970702 .08566148 1.3569952 45 0 0 .4519342 3.900189 -2.7455316 .28300282 1.1791946 46 0 0 .3147059 2.1394353 -1.0049378 .4527328 1.1803045 47 1 0 .4317869 3.8784 2.3052135 .4761297 .6700762 48 0 1 .6674441 4.1510572 7.460089 .6273525 .8361239 49 0 0 .8565682 2.551665 -1.0523659 .6250878 .9793488 50 0 1 .4982322 3.158836 10.216737 .033992387 1.335815 51 0 1 .862442 3.078727 .6887134 .1570336 1.3634286 52 1 0 .43412 2.2267342 6.813509 .4767228 1.31196 53 0 1 .7978281 3.722422 -.21783936 .5689804 1.3213422 54 0 0 .4053914 4.4891453 -1.721928 .5901511 .977384 55 1 0 .6759053 2.140832 -.7721484 .27415156 1.0441002 56 1 1 .9308016 2.1439085 -1.7045424 .5136847 1.1487762 57 1 0 .4905914 3.4354646 3.728596 .17623155 1.262743 58 1 1 .9242771 2.2605968 -2.884482 .4918295 1.36686 59 1 0 .8173962 2.9290326 -.8868616 .46810585 .8354637 60 1 1 .8188959 1.0001523 5.393549 .6210267 1.218962 61 0 0 .6643646 1.5502552 3.080465 .4693329 1.3521454 62 0 1 .5267691 2.760779 2.988858 .3717998 1.0490053 63 1 0 .7994515 3.282907 -.4839345 .4734914 .9872358 64 0 1 .017071718 2.1978106 -4.208341 .1358296 1.28503 65 1 0 .8943701 3.431186 -4.0112247 .6006962 1.3471165 66 0 1 .9916879 4.177323 -1.287177 .6200269 1.0821475 67 0 0 .7749659 3.6171284 5.57629 .29337722 .788178 68 1 1 .10337146 3.607275 5.410412 .4927406 1.263693 69 0 0 .6717248 4.994043 5.2057 .28604856 .9820552 70 1 1 .24028955 2.1008615 4.856558 .08622485 .9279749 end
Code:
foreach v in treat_1 treat_2 { reg inc1 `v', r qui outreg2 using "reg_income_`v'.tex", tex(frag) stats(coef sd) bdec(3) alpha(0.01, 0.05, 0.1) label keep(`v') nocons /// nonotes ctitle("Income 1") replace reg inc2 `v', r qui outreg2 using "reg_income_`v'.tex", tex(frag) stats(coef sd) bdec(3) alpha(0.01, 0.05, 0.1) label keep(`v') nocons /// nonotes ctitle("Income 2") append reg inc3 `v', r qui outreg2 using "reg_income_`v'.tex", tex(frag) stats(coef sd) bdec(3) alpha(0.01, 0.05, 0.1) label keep(`v') nocons /// nonotes ctitle("Income 3") append reg inc4 `v', r qui outreg2 using "reg_income_`v'.tex", tex(frag) stats(coef sd) bdec(3) alpha(0.01, 0.05, 0.1) label keep(`v') nocons /// nonotes ctitle("Income 4") append reg inc5 `v', r qui outreg2 using "reg_income_`v'.tex", tex(frag) stats(coef sd) bdec(3) alpha(0.01, 0.05, 0.1) label keep(`v') nocons /// nonotes ctitle("Income 5") append }
Comment