Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.

# Re: st: Using outreg2 within a loop

 From Suryadipta Roy To statalist@hsphsun2.harvard.edu Subject Re: st: Using outreg2 within a loop Date Wed, 13 Feb 2013 21:33:51 -0500

John,
Thank you very much indeed for the response! This is exactly what I
needed! I figured that -xttobit- does not return the adjusted
R-squared, but was carrying it over from another command.

Sincerely,

On Wed, Feb 13, 2013 at 2:56 PM, John Luke Gallup <jlgallup@pdx.edu> wrote:
>
> There is probablly a way to do this in -outreg2-, but I am not familiar with its details.
>
> If it is useful, though, you can do what you are looking for with -outreg-, also an SSC user-written command:
>
> outreg, clear
> forvalues i = 1(1)5 {
>         xttobit dep_var `controls' if period == `i', ll(0)
>         outreg using "C\file.doc", bdec(2) squarebrack keep(var1 var2) ///
> }
>
> The -keep- option strips off the sigma statistics (and the constant).  Note that there doesn't seem to be an e(r2_a) statistic saved by -xttobit-, however.  The outreg -merge- option can be used in the first iteration of a loop even if there is nothing to merge to, but it requires the -outreg, clear- command preceding the loop to prevent the endless accumulation of new columns of results when you rerun the .do file.
>
> John
>
>
> On Feb 13, 2013, at 6:43 AM, Suryadipta Roy <sroy2138@gmail.com> wrote:
>
>> Dear Statalisters,
>>
>> I am using the following form of code to get the regression results
>> within a table using -outreg2- :
>>
>> forvalues i = 1(1)5 {
>> xttobit dep_var `controls' if period == `i', ll(0)
>> outreg2 using "C:\file.doc", nocons tstat dec(2) bracket keep(var1
>> local append "append"
>> }
>>
>> When the file gets saved, two separate columns for "sigma_u" and
>> "sigma_e" are added for each of the five regressions. While I can
>> delete the columns manually, I was wondering if there is a suggestion
>> as to how to prevent them from appearing in the first place. Any
>> suggestion is greatly appreciated.
>>
>>
>> Sincerely,
>> *
>> *   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/

*
*   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/