"Best" command to output regression results

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

"Best" command to output regression results

Weichle, Thomas
Hi Statalisters,
Is there a best command to output regression results (coefficients,
confidence intervals)?  The -estimates table- command doesn't allow you
to output confidence intervals; it only allows you to output stars for
significance levels.  I came across the -estout- command and am trying
to understand its usage.  If I have saved the logistic regression
results using -estimates store model1-, can someone provide me an
example to output the ORs and confidence intervals (both rounded to 2
decimal places) in the log file?  

Eventually, I'd like to take the estimates and put them in a Word
document.  Does anyone have a suggestion to do so without having to copy
and paste each estimate into the Word document?

Tom Weichle
Math Statistician
Center for Management of Complex Chronic Care (CMC3)
Hines VA Hospital, Bldg 1, C202
708-202-8387 ext. 24261
[hidden email]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

nshephard
Administrator
On Wed, Nov 3, 2010 at 4:07 PM, Weichle, Thomas <[hidden email]> wrote:

> Hi Statalisters,
> Is there a best command to output regression results (coefficients,
> confidence intervals)?  The -estimates table- command doesn't allow you
> to output confidence intervals; it only allows you to output stars for
> significance levels.  I came across the -estout- command and am trying
> to understand its usage.  If I have saved the logistic regression
> results using -estimates store model1-, can someone provide me an
> example to output the ORs and confidence intervals (both rounded to 2
> decimal places) in the log file?
>
> Eventually, I'd like to take the estimates and put them in a Word
> document.  Does anyone have a suggestion to do so without having to copy
> and paste each estimate into the Word document?

My "best" way is to do this with -estout- (although I never use M$-Word).

There is plenty of discussion on this very topic in the Statalist
archives (see URL in the bottom of Statalist mails for links to
searchable archives).

There was even a thread yesterday which touched on it and included some code.

Neil


--
"Our civilization would be pitifully immature without the intellectual
revolution led by Darwin" - Motoo Kimura, The Neutral Theory of
Molecular Evolution

Email - [hidden email]
Website - http://kimura-no-ip.org/
Photos - http://www.flickr.com/photos/slackline/

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Fred Wolfe
In reply to this post by Weichle, Thomas
What's best depends on what you want to do over and over again.

In general, I am usually satisfied with the regression output from
Stata. From a log file or even from a screen copy, I move all of the
results to a text editor. With a few key strokes I extract just the
regression results (this usually requires a little programming or
manipulation in the text editor). Then I paste the output into Excel,
use "Text to Columns" and an Excel formula to move the CIs together
and to properly format the number of Decimal places. This is then
pasted into MS word.

It takes a little while to figure out how to do this. But once set up
is very fast.  It's suitable for multiple tables. I also use the
method for tables of descriptive statistics. It's possible to process
many tables at once, so it is very fast. Like others, I would like
Stata to be able to make better tables and output, but until that
happens this method works best for me. I am sure other methods work
best for others.

Fred

PS. Here are my notes:

Get Coefficients (HR, OR, etc.), 95% CI, and p value for Word tables
from regression output
    Paste 7 column regression output into Excel
    Use text to column in data menu. Remove se and t, leaving 5 columns
    Do not format cells
    Insert 2 columns before P>z
    Insert P>z into Column D
    Place cursor in C2, and paste in one of the below functions,
depending on decimal points
    =CONCATENATE(FIXED(B1,1)," (",FIXED(F1,1),", ",FIXED(G1,1),")")
    =CONCATENATE(FIXED(B1,2)," (",FIXED(F1,2),", ",FIXED(G1,2),")")
    =CONCATENATE(FIXED(B1,3)," (",FIXED(F1,3),", ",FIXED(G1,3),")")
    =CONCATENATE(FIXED(B2,1)," (",FIXED(F2,1),", ",FIXED(G1,1),")")
    =CONCATENATE(FIXED(B2,2)," (",FIXED(F2,2),", ",FIXED(G1,2),")")
    =CONCATENATE(FIXED(B2,13)," (",FIXED(F2,3),", ",FIXED(G1,3),")")
    Expand function by dragging
    Copy first 4 columns to Word, and delete column 2


Fred

On Wed, Nov 3, 2010 at 11:07 AM, Weichle, Thomas <[hidden email]> wrote:

>
> Hi Statalisters,
> Is there a best command to output regression results (coefficients,
> confidence intervals)?  The -estimates table- command doesn't allow you
> to output confidence intervals; it only allows you to output stars for
> significance levels.  I came across the -estout- command and am trying
> to understand its usage.  If I have saved the logistic regression
> results using -estimates store model1-, can someone provide me an
> example to output the ORs and confidence intervals (both rounded to 2
> decimal places) in the log file?
>
> Eventually, I'd like to take the estimates and put them in a Word
> document.  Does anyone have a suggestion to do so without having to copy
> and paste each estimate into the Word document?
>
> Tom Weichle
> Math Statistician
> Center for Management of Complex Chronic Care (CMC3)
> Hines VA Hospital, Bldg 1, C202
> 708-202-8387 ext. 24261
> [hidden email]
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/



--
Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
NDB Office  +1 316 263 2125 Ext 0
Research Office +1 316 686 9195
[hidden email]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Austin Nichols
In reply to this post by Weichle, Thomas
Thomas <[hidden email]>:
A lot of the work happens in Word, if that is your platform.  -esttab-
(part of -estout- on SSC) writes out RTF files with the rtf option
that can be easily included in a Word file using the Insert...File...
dialog in Word.  See also -png2rtf- on SSC for a program to write
graphs to RTF, and see its help file for alternative methods--if you
are writing out a thousand graphs you may prefer Michael Blasnik's
method using a mail merge.  It takes some work to set up though, so if
you only have a few tables and a few graphs it will probably not be
worthwhile to set up a mail merge.  In TeX or LaTeX, you can directly
\include all kinds of things, but I don't know of a similar trick for
Word, aside from the mail merge.

On Wed, Nov 3, 2010 at 12:07 PM, Weichle, Thomas <[hidden email]> wrote:

> Hi Statalisters,
> Is there a best command to output regression results (coefficients,
> confidence intervals)?  The -estimates table- command doesn't allow you
> to output confidence intervals; it only allows you to output stars for
> significance levels.  I came across the -estout- command and am trying
> to understand its usage.  If I have saved the logistic regression
> results using -estimates store model1-, can someone provide me an
> example to output the ORs and confidence intervals (both rounded to 2
> decimal places) in the log file?
>
> Eventually, I'd like to take the estimates and put them in a Word
> document.  Does anyone have a suggestion to do so without having to copy
> and paste each estimate into the Word document?
>
> Tom Weichle
> Math Statistician
> Center for Management of Complex Chronic Care (CMC3)
> Hines VA Hospital, Bldg 1, C202
> 708-202-8387 ext. 24261
> [hidden email]

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Eric A. Booth
In reply to this post by Fred Wolfe
<>

Fred -

You can do this from -estout- (from SSC) without the copy/pasting, concatenating, etc.  

Here's an example that will produce & open tables in Word and Excel (in Word, you'll still need to use the 'text to columns' function, unless you set up some kind of mail merge as Austin has mentioned).  Also, you probably will want to play with the CI formatting in the cells() option -- I'm not familiar with the Excel formulas that you describe.
 If you're creating many tables, there shouldn't be any need to do this much clicking, formatting, and pasting as much of it should be able to be automated by one of the various Stata user packages designed for this purpose.    -outreg2- can probably do most, if not all, of what you describe as well.


*****************!
clear
sysuse auto, clear
estimates clear
**

foreach ext in xls doc  {
foreach iv in mpg price headroom {

logit for rep78 length turn `iv', or
est store Model_`iv'
}

estout * using "test.`ext'", replace ///
   cells("b(star fmt(3)) ci(par([  ]--[  ]) fmt(2))   p(fmt(2))" ) ///
    stats(r2_p chi2 bic N)  collabels("OR" "CI" "P>z")  
       
/*  Note: remove the quotes in the cells()  
    option above to stack the stats vertically  
*/  


//open tables in Windows or Mac OSX//
if "`c(os)'" == "MacOSX" local i open
if "`c(os)'" == "Windows" local i start
!`i' "test.`ext'"
}
*****************!

- Eric

__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[hidden email]
Office: +979.845.6754
Fax: +979.845.0249
http://ppri.tamu.edu


On Nov 3, 2010, at 11:35 AM, Fred Wolfe wrote:

> What's best depends on what you want to do over and over again.
>
> In general, I am usually satisfied with the regression output from
> Stata. From a log file or even from a screen copy, I move all of the
> results to a text editor. With a few key strokes I extract just the
> regression results (this usually requires a little programming or
> manipulation in the text editor). Then I paste the output into Excel,
> use "Text to Columns" and an Excel formula to move the CIs together
> and to properly format the number of Decimal places. This is then
> pasted into MS word.
>
> It takes a little while to figure out how to do this. But once set up
> is very fast.  It's suitable for multiple tables. I also use the
> method for tables of descriptive statistics. It's possible to process
> many tables at once, so it is very fast. Like others, I would like
> Stata to be able to make better tables and output, but until that
> happens this method works best for me. I am sure other methods work
> best for others.
>
> Fred
>
> PS. Here are my notes:
>
> Get Coefficients (HR, OR, etc.), 95% CI, and p value for Word tables
> from regression output
>    Paste 7 column regression output into Excel
>    Use text to column in data menu. Remove se and t, leaving 5 columns
>    Do not format cells
>    Insert 2 columns before P>z
>    Insert P>z into Column D
>    Place cursor in C2, and paste in one of the below functions,
> depending on decimal points
>    =CONCATENATE(FIXED(B1,1)," (",FIXED(F1,1),", ",FIXED(G1,1),")")
>    =CONCATENATE(FIXED(B1,2)," (",FIXED(F1,2),", ",FIXED(G1,2),")")
>    =CONCATENATE(FIXED(B1,3)," (",FIXED(F1,3),", ",FIXED(G1,3),")")
>    =CONCATENATE(FIXED(B2,1)," (",FIXED(F2,1),", ",FIXED(G1,1),")")
>    =CONCATENATE(FIXED(B2,2)," (",FIXED(F2,2),", ",FIXED(G1,2),")")
>    =CONCATENATE(FIXED(B2,13)," (",FIXED(F2,3),", ",FIXED(G1,3),")")
>    Expand function by dragging
>    Copy first 4 columns to Word, and delete column 2
>
>
> Fred
>
> On Wed, Nov 3, 2010 at 11:07 AM, Weichle, Thomas <[hidden email]> wrote:
>>
>> Hi Statalisters,
>> Is there a best command to output regression results (coefficients,
>> confidence intervals)?  The -estimates table- command doesn't allow you
>> to output confidence intervals; it only allows you to output stars for
>> significance levels.  I came across the -estout- command and am trying
>> to understand its usage.  If I have saved the logistic regression
>> results using -estimates store model1-, can someone provide me an
>> example to output the ORs and confidence intervals (both rounded to 2
>> decimal places) in the log file?
>>
>> Eventually, I'd like to take the estimates and put them in a Word
>> document.  Does anyone have a suggestion to do so without having to copy
>> and paste each estimate into the Word document?
>>
>> Tom Weichle
>> Math Statistician
>> Center for Management of Complex Chronic Care (CMC3)
>> Hines VA Hospital, Bldg 1, C202
>> 708-202-8387 ext. 24261
>> [hidden email]
>>
>> *
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/statalist/faq
>> *   http://www.ats.ucla.edu/stat/stata/
>
>
>
> --
> Fred Wolfe
> National Data Bank for Rheumatic Diseases
> Wichita, Kansas
> NDB Office  +1 316 263 2125 Ext 0
> Research Office +1 316 686 9195
> [hidden email]
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/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/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Eric A. Booth
<>

[correction] I left out the "eform" option in the -estout- command in my example to display the ORs instead of coefficients in the Excel/Word tables.

- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[hidden email]


On Nov 3, 2010, at 1:56 PM, Eric Booth wrote:

> <>
>
> Fred -
>
> You can do this from -estout- (from SSC) without the copy/pasting, concatenating, etc.  
>
> Here's an example that will produce & open tables in Word and Excel (in Word, you'll still need to use the 'text to columns' function, unless you set up some kind of mail merge as Austin has mentioned).  Also, you probably will want to play with the CI formatting in the cells() option -- I'm not familiar with the Excel formulas that you describe.
> If you're creating many tables, there shouldn't be any need to do this much clicking, formatting, and pasting as much of it should be able to be automated by one of the various Stata user packages designed for this purpose.    -outreg2- can probably do most, if not all, of what you describe as well.
>
>
> *****************!
> clear
> sysuse auto, clear
> estimates clear
> **
>
> foreach ext in xls doc  {
> foreach iv in mpg price headroom {
>
> logit for rep78 length turn `iv', or
> est store Model_`iv'
> }
>
> estout * using "test.`ext'", replace ///
>   cells("b(star fmt(3)) ci(par([  ]--[  ]) fmt(2))   p(fmt(2))" ) ///
>    stats(r2_p chi2 bic N)  collabels("OR" "CI" "P>z")  
>
> /*  Note: remove the quotes in the cells()  
>    option above to stack the stats vertically  
> */  
>
>
> //open tables in Windows or Mac OSX//
> if "`c(os)'" == "MacOSX" local i open
> if "`c(os)'" == "Windows" local i start
> !`i' "test.`ext'"
> }
> *****************!
>
> - Eric
>
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [hidden email]
> Office: +979.845.6754
> Fax: +979.845.0249
> http://ppri.tamu.edu
>
>
> On Nov 3, 2010, at 11:35 AM, Fred Wolfe wrote:
>
>> What's best depends on what you want to do over and over again.
>>
>> In general, I am usually satisfied with the regression output from
>> Stata. From a log file or even from a screen copy, I move all of the
>> results to a text editor. With a few key strokes I extract just the
>> regression results (this usually requires a little programming or
>> manipulation in the text editor). Then I paste the output into Excel,
>> use "Text to Columns" and an Excel formula to move the CIs together
>> and to properly format the number of Decimal places. This is then
>> pasted into MS word.
>>
>> It takes a little while to figure out how to do this. But once set up
>> is very fast.  It's suitable for multiple tables. I also use the
>> method for tables of descriptive statistics. It's possible to process
>> many tables at once, so it is very fast. Like others, I would like
>> Stata to be able to make better tables and output, but until that
>> happens this method works best for me. I am sure other methods work
>> best for others.
>>
>> Fred
>>
>> PS. Here are my notes:
>>
>> Get Coefficients (HR, OR, etc.), 95% CI, and p value for Word tables
>> from regression output
>>   Paste 7 column regression output into Excel
>>   Use text to column in data menu. Remove se and t, leaving 5 columns
>>   Do not format cells
>>   Insert 2 columns before P>z
>>   Insert P>z into Column D
>>   Place cursor in C2, and paste in one of the below functions,
>> depending on decimal points
>>   =CONCATENATE(FIXED(B1,1)," (",FIXED(F1,1),", ",FIXED(G1,1),")")
>>   =CONCATENATE(FIXED(B1,2)," (",FIXED(F1,2),", ",FIXED(G1,2),")")
>>   =CONCATENATE(FIXED(B1,3)," (",FIXED(F1,3),", ",FIXED(G1,3),")")
>>   =CONCATENATE(FIXED(B2,1)," (",FIXED(F2,1),", ",FIXED(G1,1),")")
>>   =CONCATENATE(FIXED(B2,2)," (",FIXED(F2,2),", ",FIXED(G1,2),")")
>>   =CONCATENATE(FIXED(B2,13)," (",FIXED(F2,3),", ",FIXED(G1,3),")")
>>   Expand function by dragging
>>   Copy first 4 columns to Word, and delete column 2
>>
>>
>> Fred
>>
>> On Wed, Nov 3, 2010 at 11:07 AM, Weichle, Thomas <[hidden email]> wrote:
>>>
>>> Hi Statalisters,
>>> Is there a best command to output regression results (coefficients,
>>> confidence intervals)?  The -estimates table- command doesn't allow you
>>> to output confidence intervals; it only allows you to output stars for
>>> significance levels.  I came across the -estout- command and am trying
>>> to understand its usage.  If I have saved the logistic regression
>>> results using -estimates store model1-, can someone provide me an
>>> example to output the ORs and confidence intervals (both rounded to 2
>>> decimal places) in the log file?
>>>
>>> Eventually, I'd like to take the estimates and put them in a Word
>>> document.  Does anyone have a suggestion to do so without having to copy
>>> and paste each estimate into the Word document?
>>>
>>> Tom Weichle
>>> Math Statistician
>>> Center for Management of Complex Chronic Care (CMC3)
>>> Hines VA Hospital, Bldg 1, C202
>>> 708-202-8387 ext. 24261
>>> [hidden email]
>>>
>>> *
>>> *   For searches and help try:
>>> *   http://www.stata.com/help.cgi?search
>>> *   http://www.stata.com/support/statalist/faq
>>> *   http://www.ats.ucla.edu/stat/stata/
>>
>>
>>
>> --
>> Fred Wolfe
>> National Data Bank for Rheumatic Diseases
>> Wichita, Kansas
>> NDB Office  +1 316 263 2125 Ext 0
>> Research Office +1 316 686 9195
>> [hidden email]
>>


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: "Best" command to output regression results

Nick Cox
In reply to this post by Eric A. Booth
Exactly! This is a standard trade-off and it bites experienced users almost as much as new users, and no one has an easy answer.

Fred worked out how to do what he wanted and now can "routinize" it (a word that is ugly but accurate here): meaning, he can repeat his procedure with much less stress than when he first worked it out, and indeed vary it a bit as needed.

There are undoubtedly other ways to do it, but sometimes with a complicated command it can take you as long to understand the complicated command's way of thinking about your problem as doing it from scratch using basic tools.

It's not easy for programmers either. You can think you've designed a Swiss Army knife, with lots of useful extra bits, but to users it might look just like a Heath Robinson design.

U.S. readers: substitute "Rube Goldberg".
Other readers: sorry, I don't know other equivalents.

Nick
[hidden email]

Eric Booth

You can do this from -estout- (from SSC) without the copy/pasting, concatenating, etc.  

Here's an example that will produce & open tables in Word and Excel (in Word, you'll still need to use the 'text to columns' function, unless you set up some kind of mail merge as Austin has mentioned).  Also, you probably will want to play with the CI formatting in the cells() option -- I'm not familiar with the Excel formulas that you describe.
 If you're creating many tables, there shouldn't be any need to do this much clicking, formatting, and pasting as much of it should be able to be automated by one of the various Stata user packages designed for this purpose.    -outreg2- can probably do most, if not all, of what you describe as well.


*****************!
clear
sysuse auto, clear
estimates clear
**

foreach ext in xls doc  {
foreach iv in mpg price headroom {

logit for rep78 length turn `iv', or
est store Model_`iv'
}

estout * using "test.`ext'", replace ///
   cells("b(star fmt(3)) ci(par([  ]--[  ]) fmt(2))   p(fmt(2))" ) ///
    stats(r2_p chi2 bic N)  collabels("OR" "CI" "P>z")  
       
/*  Note: remove the quotes in the cells()  
    option above to stack the stats vertically  
*/  


//open tables in Windows or Mac OSX//
if "`c(os)'" == "MacOSX" local i open
if "`c(os)'" == "Windows" local i start
!`i' "test.`ext'"
}
*****************!

On Nov 3, 2010, at 11:35 AM, Fred Wolfe wrote:

> What's best depends on what you want to do over and over again.
>
> In general, I am usually satisfied with the regression output from
> Stata. From a log file or even from a screen copy, I move all of the
> results to a text editor. With a few key strokes I extract just the
> regression results (this usually requires a little programming or
> manipulation in the text editor). Then I paste the output into Excel,
> use "Text to Columns" and an Excel formula to move the CIs together
> and to properly format the number of Decimal places. This is then
> pasted into MS word.
>
> It takes a little while to figure out how to do this. But once set up
> is very fast.  It's suitable for multiple tables. I also use the
> method for tables of descriptive statistics. It's possible to process
> many tables at once, so it is very fast. Like others, I would like
> Stata to be able to make better tables and output, but until that
> happens this method works best for me. I am sure other methods work
> best for others.
>
> Fred
>
> PS. Here are my notes:
>
> Get Coefficients (HR, OR, etc.), 95% CI, and p value for Word tables
> from regression output
>    Paste 7 column regression output into Excel
>    Use text to column in data menu. Remove se and t, leaving 5 columns
>    Do not format cells
>    Insert 2 columns before P>z
>    Insert P>z into Column D
>    Place cursor in C2, and paste in one of the below functions,
> depending on decimal points
>    =CONCATENATE(FIXED(B1,1)," (",FIXED(F1,1),", ",FIXED(G1,1),")")
>    =CONCATENATE(FIXED(B1,2)," (",FIXED(F1,2),", ",FIXED(G1,2),")")
>    =CONCATENATE(FIXED(B1,3)," (",FIXED(F1,3),", ",FIXED(G1,3),")")
>    =CONCATENATE(FIXED(B2,1)," (",FIXED(F2,1),", ",FIXED(G1,1),")")
>    =CONCATENATE(FIXED(B2,2)," (",FIXED(F2,2),", ",FIXED(G1,2),")")
>    =CONCATENATE(FIXED(B2,13)," (",FIXED(F2,3),", ",FIXED(G1,3),")")
>    Expand function by dragging
>    Copy first 4 columns to Word, and delete column 2

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Austin Nichols
But...
-esttab- is the user-friendly version of the program the poster
mentions, installed along with -estout- from SSC, and therefore is the
obvious "easy answer" for that question. It even has its own webpage
(http://repec.org/bocode/e/estout/) with worked examples.  Here are
some useful options demonstrated; the last line is specific to those
who want a MSWindows/MSWord example:

clear all
sysuse auto
qui reg foreign weight
est sto LPM
qui logistic foreign weight
est sto Logit
est sto OR
loc opt "la rtf onecell nogaps mti replace eqlabels(none)"
esttab * using r.doc, eform(0 0 1) `opt'
!start r.doc

On Wed, Nov 3, 2010 at 3:14 PM, Nick Cox <[hidden email]> wrote:
> Exactly! This is a standard trade-off and it bites experienced users almost as much as new users, and no one has an easy answer.

> Eric Booth
> You can do this from -estout- (from SSC) without the copy/pasting, concatenating, etc.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Weichle, Thomas
In reply to this post by Weichle, Thomas
Hi Eric,
I'm using the code you provided and it seems to work fine.  However, do
you know how to create a 2007 Microsoft Word document (.docx)?  I simply
tried to replace the extension .doc with .docx and it doesn't work.
Also, is there a way to have the document created in landscape format
instead of portrait format?  This code puts the 2 model results right
next to each other.  Is there a way to put one after the other?  Do you
see anything else for improvement with this code?

foreach mod in colon_post lung_post {
estimates restore `mod'
estout * using "LOGISTIC_MODELS_test3.doc", cells("b(fmt(2)) ci(par((  -
)) fmt(2)) p(fmt(3))") stats(N) legend style(fixed) eform replace label
collabels("Odds Ratio" "95% C.I." "P>|z|") varwidth(25) modelwidth(10)
prefoot("") postfoot("")

}

* Open tables in Windows
if "`c(os)'" == "Windows" local i start !`i' "LOGISTIC_MODELS_test3.doc"

Tom Weichle
Math Statistician
Center for Management of Complex Chronic Care (CMC3)
Hines VA Hospital, Bldg 1, C202
708-202-8387 ext. 24261
[hidden email]


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: "Best" command to output regression results

Eric A. Booth
<>

My replies are included in-line below:


On Nov 4, 2010, at 10:28 AM, Weichle, Thomas wrote:

> Hi Eric,
> I'm using the code you provided and it seems to work fine.  However, do
> you know how to create a 2007 Microsoft Word document (.docx)?  I simply
> tried to replace the extension .doc with .docx and it doesn't work.

If I change the extensions to .xlsx or .docx, Stata/-estout- will still output the file, but the issue seems to be that it's not in a format MS Office can understand (or possibly, some versions of MS Office can understand).  Unexpectedly, I found that my set-up will produce & open a .docx using your -estout- example, however the .xlsx file won't open -- it gives me an error that the document "seems corrupt".  ( &  I'm not sure of the mechanics behind what -estout- or similar packages can or already do to make the document compatible with the new(ish) .docx/.xlsx formats )   I am using Stata MP on a MacOSX 10.6 with MS Office 2011 Business Edition.  


> Also, is there a way to have the document created in landscape format
> instead of portrait format?  

It doesn't appear that this is part of -estout- , and I've never tried getting something into landscape from Stata before, but you could probably get this capability from other packages if you wanted to avoid changing these properties manually in Word.

One suggestion is to look at some of the RTF solutions (example:   Newson's -rtfutil- (from SSC) will let you define the papersize()).

Also, you could send the tables to smcl and then convert it to ps or pdf (Mac only) and specify some options about the page margins, font, and orientation, but that still gets you back to the issue of automation (you'd have to import/paste that into the Word document unless, again, you go to a Excel-to-Word mail merge or linked document solution or use something like latex to \include the pdf/ps).  Be sure to change the 'style()' in the -estout- to 'style(smcl)' if you pursue this option.   Take a look at "translator query smcl2ps" to see the options you can change (esp. pagesize() or margins()).

 Finally, latex is always a good solution when you need to automate any application of page formatting.  

> This code puts the 2 model results right
> next to each other.  Is there a way to put one after the other?  

Yes, just run the -estout- commands for each model separately and use the "append" option for -estout- after the first one.  So instead of :

estout * <using>,  replace  ....


   separate it out into:

estout Model1 using "test.doc", replace  ....
...
estout  Model2 using "test.doc", append ....
...
estout Model3 using "test.doc", append ....
...

or better yet, put this in a loop:

******
cap erase  "test.doc"
forval n = 1/10 {
        estout Model`n' using "test.doc", append ...
}
******
 
- Eric
__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[hidden email]
Office: +979.845.6754





*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
Loading...