Announcement

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

  • Outreg2- r(603)- Cannot Open File

    Hello All,

    I'm running a linear regression and planned to use outreg2 to organize the results. My version is STATA 13, fully updated, and the latest version of outreg2, and I was able to run outreg2 for several months with no issues, so this is a recent issue as of the last couple of weeks.

    This is my coding:
    outreg2 using myreg.doc, replace ctitle(Model1)

    The error is that file myreg.txt cannot be opened. I've looked at some threads noting that slowing down the speed of outreg2 can help, but the sleep option isn't allowed, so that fix has't worked.

    Any thoughts/aid would be much appreciated.

    Josh Alley

  • #2
    Are you saving it in a dropbox folder? That happened to me before when running regressions in a loop so in the first run dropbox locks the file for a few seconds, and then on the second run outreg2 can't save the file. A quick but dirty solution would be to do

    Code:
    local cmd outreg2...
    cap `cmd'
    if (_rc) {
    sleep 1000
    `cmd'
    }
    This allows for one failure.

    Best,
    S

    Comment


    • #3
      Sergio,

      Thanks for the suggestion! I'm not saving it to a dropbox folder, but I did run that bit of code to see if it would have the same result. That was unsuccessful.

      I also tried deleting the myreg document to see if a fresh version of it would do the trick, but that didn't work. None of my folders are read-only, which eliminates that option for why STATA can't open the document.

      Thanks again,
      Josh

      Comment


      • #4
        That might also happen when you are using a hard drive that is slow or takes time. Try changing your working directory to some other folders.
        Regards
        --------------------------------------------------
        Attaullah Shah, PhD.
        Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
        FinTechProfessor.com
        https://asdocx.com
        Check out my asdoc program, which sends outputs to MS Word.
        For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

        Comment


        • #5
          Professor Shah,

          Changing the directory did the trick. Thanks for that suggestion!

          Best,
          Josh Alley

          Comment


          • #6
            Thanks Professor Shah, that also worked for me. Much appreciated, NR

            Comment


            • #7
              Thanks Professor Shah, I found it useful too

              Comment


              • #8
                Originally posted by Sergio Correia View Post
                Are you saving it in a dropbox folder? That happened to me before when running regressions in a loop so in the first run dropbox locks the file for a few seconds, and then on the second run outreg2 can't save the file. A quick but dirty solution would be to do

                Code:
                local cmd outreg2...
                cap `cmd'
                if (_rc) {
                sleep 1000
                `cmd'
                }
                This allows for one failure.

                Best,
                S
                Thanks Sergio. I forgot that I was working on dropbox and couldn't understand why I kept getting random file access problems.

                TIP: Pause Dropbox's synchronization (through the icon in the tray). This way you won't have to change folders and you can keep working in Dropbox.

                Comment


                • #9
                  Originally posted by Attaullah Shah View Post
                  That might also happen when you are using a hard drive that is slow or takes time. Try changing your working directory to some other folders.
                  I am not using a hard-disk. But I am using a computer in the Econ Lab of my Univ. I had been using outreg2 for months. I always use .xls but i am getting this error r603 saying reg.txt could not be opened.
                  How to change working directory? I have never set any working directory.

                  My code is:
                  regress cumm_fert v133 v012 age2 v715 v730 headsex sc_dummy st_dummy muslim_dummy dist_state2-dist_state440 time2-time40 if (sample_97==1 & sample_state==1)[pweight=v005],cluster(dist_state)
                  outreg2 using reg(2).xls, addtext(Time FE, Yes, District FE , Yes) keep (v133 v012 age2 v715 v730 headsex sc_dummy st_dummy muslim_dummy)

                  Comment


                  • #10
                    As a simple solution, make a directory in C drive, with the name results and change your directory to this folder, e.g,
                    Code:
                    mkdir C:/results
                    cd C:/results
                    Regards
                    --------------------------------------------------
                    Attaullah Shah, PhD.
                    Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                    FinTechProfessor.com
                    https://asdocx.com
                    Check out my asdoc program, which sends outputs to MS Word.
                    For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                    Comment


                    • #11
                      Dear Attaullah,
                      Your suggestion just helped. Thanks for posting.

                      Dapel

                      Comment


                      • #12
                        Hi,

                        Stata shows me the message file /Users/<username>/Dropbox/<folder1>/<folder2>/<folder3>/reg_TonChar_phase2.txt could not be opened after it runs the outreg2 command in this code:

                        forval phase=2/6 {

                        reg t1 $bl_char $bl_health if phase`phase'==1
                        est store t1p`phase'
                        test $bl_char
                        local F`phase'_char=r(p)
                        test $bl_health
                        local F`phase'_health=r(p)
                        test $bl_char $bl_health
                        local F`phase'_all=r(p)

                        outreg2 using "${output}reg_TonChar_phase`phase'", se dec(2) 10pct nocon label adec(2) ///
                        addstat(F test for demographics, `F`phase'_char', F test for health, `F`phase'_health', F test for all RHS, `F`phase'_all') ///
                        word title("Regress treatment indicator on baseline characteristics (Phase `phase')") replace

                        }

                        I use Stata 12.1.

                        Any suggestions please?

                        Comment


                        • #13
                          Dear Sir Attaullah Shah Thank you so much for this its really work. I was stuck whiles hours to found some solution and finally saw your post and sort out my problem.

                          Comment


                          • #14
                            Farrukh Shahzad Thanks for your kind words. Outreg2 is a great program for exporting regression output. Recently I wrote asdoc program that can export output to MS Word from various types of regression commands, summary statistics, correlations, tabulation commands and many more. Following are few resources related to asdoc.
                            Code:
                            ssc install asdoc
                            help asdoc
                            YouTube video : Creating descriptive statistics with asdoc
                            YouTube video : Create a publication quality table of correlation in Stata with asdoc
                            YouTube video : Create publication quality regression tables in Stata with asdoc
                            YouTube video : Writing all stats to a single Word file


                            Blog post : A simple example to get started with asdoc
                            Blog post : How to export high-quality table of correlations from Stata to MS Word
                            Blog post : Exporting tabs and cross-tabs to MS Word from Stata with asdoc

                            Regards
                            --------------------------------------------------
                            Attaullah Shah, PhD.
                            Professor of Finance, Institute of Management Sciences Peshawar, Pakistan
                            FinTechProfessor.com
                            https://asdocx.com
                            Check out my asdoc program, which sends outputs to MS Word.
                            For more flexibility, consider using asdocx which can send Stata outputs to MS Word, Excel, LaTeX, or HTML.

                            Comment


                            • #15
                              Dear Professor Attaullah Shah.
                              Thank you for your post. Changing my dir fixed the problem perfectly.

                              Comment

                              Working...
                              X