Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Problem with outreg
From
John Luke Gallup <[email protected]>
To
[email protected]
Subject
Re: st: Problem with outreg
Date
Tue, 29 Jan 2013 23:52:56 -0800
Wameq,
With -outreg-, including -using <filename>- makes -outreg- write the table to the file <filename>.
You want to create two complex tables by merging results and write them below each other in a single file.
The key is to create the complete first table before writing it to a file, and then create the complete second table before writing it to a file (with the -addtable- option).
You have something like this:
reg 1.1
outreg using table // writes table containing reg 1.1 results
reg 1.2
outreg using table, merge // overwrites file with table containing reg 1.1 and reg 1.2 results
reg 2.1
outreg using table, addtable // adds table containing reg 2.1 results below Table 1
reg 2.2
outreg using table, merge // overwrites file with table containing reg 2.1 and reg 2.2 results
The -outreg- command after reg 2.2 creates a table which merges the regression output with reg 2.1 output and _overwrites_ the file named "table.doc", eliminating your first table. -outreg- overwrites "table.doc" because -merge- implies -replace-.
You want is something like this:
reg 1.1
outreg
reg 1.2
outreg using table, merge
reg 2.1
outreg
reg 2.2
outreg using table, merge addtable
I think the following code should work:
*Table 1:
reg lna att in_att YE var1 var2 var3
outreg, ctitle("Variable", "Short term Illnesses")
starloc(1) starlevels(10 5 1) se replace
reg lnc att in_att YE var1 var2 var3
outreg, ctitle("Variable", "Long term Illnesses")
starloc(1) starlevels(10 5 1) merge se
reg lni att in_att YE var1 var2 var3
outreg using table, ctitle("Variable", "Inpatient Care") title ("OLS
results for health care expenses (Dep var: total health care cost for
the last visit to the doctor)") starloc(1) starlevels(10 5 1)//
//merge note("The figures show marginal effects and standard errors
for each category") se
*Table 2:
probit care_hw_a_all att in_att YE var1 var2 var3
margins, dydx (_all)
outreg, marginal ctitle("Variable", "Short term
Illnesses") starloc(1) starlevels(10 5 1) se
probit care_hw_c_all att in_att YE var1 var2 var3
margins, dydx (_all)
outreg, merge marginal ctitle("Variable", "Long term
Illnesses") starloc(1) starlevels(10 5 1) se
probit care_hw_i_all att in_att YE var1 var2 var3
margins, dydx (_all)
outreg using table, addtable marginal ctitle("Variable", "Inpatient Care")
title ("Probit results for who reports an illness (Dep var: Binary var
for those who reported an illness)") starloc(1) starlevels(10 5// //1)
merge note("The figures show marginal effects and standard errors for
each category") se
John
On Jan 29, 2013, at 11:30 PM, Wameq Raza <[email protected]> wrote:
> Dear Stata users,
> I'm facing some problem creating a whole document of tables using
> outreg and was hoping someone would be able to help me. I have about 6
> tables that I need to be able to put in one single document (for
> brevity's sake I'm including the syntax for the first 2). What happens
> when I fun the following is that the first table comes out just fine,
> but as soon as the second table runs, it ends up replacing the first
> one in the document. By the time the syntax finishes running for all 6
> tables, I'm just left with Table number 6 in the document and the rest
> aren't there.
>
> I have isolated the problem to the second regression for table 2. The
> first regression seems to be fine, but when it comes to running outreg
> for the second one, it deletes all the results from table 1. If I add
> in "addtable" along with merge, then the problem of deletion goes
> away, but I'm also left with an extra row that I have to manually
> delete. Depending on the number of regressions, this really builds up!
> I have a feeling I'm overlooking some simple mistake, but I'm not
> being able to put my finger on it.
>
> Could anyone please kindly suggest a solution?
> Best
> Wameq
>
>
> *Table 1:
> reg lna att in_att YE var1 var2 var3
> outreg using table, ctitle("Variable", "Short term Illnesses")
> starloc(1) starlevels(10 5 1) se replace
> reg lnc att in_att YE var1 var2 var3
> outreg using table, ctitle("Variable", "Long term Illnesses")
> starloc(1) starlevels(10 5 1) merge se
> reg lni att in_att YE var1 var2 var3
> outreg using table, ctitle("Variable", "Inpatient Care") title ("OLS
> results for health care expenses (Dep var: total health care cost for
> the last visit to the doctor)") starloc(1) starlevels(10 5 1)//
> //merge note("The figures show marginal effects and standard errors
> for each category") se
>
> *Table 2:
> probit care_hw_a_all att in_att YE var1 var2 var3
> margins, dydx (_all)
> outreg using table, addtable marginal ctitle("Variable", "Short term
> Illnesses") starloc(1) starlevels(10 5 1) se
> probit care_hw_c_all att in_att YE var1 var2 var3
> margins, dydx (_all)
> outreg using table, merge marginal ctitle("Variable", "Long term
> Illnesses") starloc(1) starlevels(10 5 1) se
> probit care_hw_i_all att in_att YE var1 var2 var3
> margins, dydx (_all)
> outreg using table, marginal ctitle("Variable", "Inpatient Care")
> title ("Probit results for who reports an illness (Dep var: Binary var
> for those who reported an illness)") starloc(1) starlevels(10 5// //1)
> merge note("The figures show marginal effects and standard errors for
> each category") se
>
>
> --
> W A M E Q R A Z A
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/