Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Stata thinks files are read-only when they shouldn't be!


From   kokootchke <[email protected]>
To   statalist <[email protected]>
Subject   RE: st: Stata thinks files are read-only when they shouldn't be!
Date   Mon, 11 May 2009 02:12:46 -0400

Thanks to everyone for your suggestions. Just to follow up on this issue, I'm definitely not leaving files open that are causing problems when I run the do file. As I said, sometimes I run a do file that creates a .dta file from scratch, makes changes to it, and then tries to overwrite this file (save, replace), and then I get the error! So I definitely think it has something to do with the processing speed or something like that, like some of you suggested.
I also noticed that this was happening with a desktop I'm using that has Stata 9 but not with my laptop that has Stata 10 (and yes, I have Windows XP on both machines). Since I have a deadline tomorrow, I simply stopped using the machine that has Stata 9 to avoid these issues altogether for now... but as soon as I'm done with my deadline, I will try and implement these solutions you guys suggested and get back to you.
Thanks a lot!
Adrian

> From: [email protected]
> To: [email protected]
> Subject: Re: st: Stata thinks files are read-only when they shouldn't be!
> Date: Sun, 10 May 2009 22:59:29 -0500
> 
> Roy is right that the problem might be that Adrian is opening his text  
> file before Stata has finished.  Additionally, it might be that Adrian  
> has opened the text file, left it open, and tried to run the do-file  
> again.  If so, this may produce the same error.
> 
> So, to add to my previous suggestions about telling DOS to give read- 
> write attributes to the text file and telling Stata to sleep for a  
> bit, maybe Adrian needs to add a command to tell Windows to close his  
> text program before running each iteration of the loop, just in case  
> he left it open or he tries to peek at it too early.
> 
> So you might add the line:
> 
> 	winexec taskkill /F /IM Notepad.exe /T
> 
> if you were using Windows XP and you were opening your  
> "myfile_happ.txt" file in notepad.  You'll need to adjust this  
> according to the program you are using to look at the .txt file.
> 
> Additionally, if you are using Mac or linux, you can use the command:
> 
> 	!osascript -e 'tell application "TextEdit" to quit'
> 
> to close the text editor (if you were using TextEdit in MacOSX to look  
> at your .txt file).
> 
> You can put this line at the beginning of your loop and the OS will  
> ignore it if you've already closed the text editor.
> 
> 
> 
> Best,
> 
> Eric
> 
> __
> Eric A. Booth
> Public Policy Research Institute
> Texas A&M University
> [email protected]
> Office: +979.845.6754
> 
> 
> 
> 
> On May 10, 2009, at 8:03 PM, Roy Wada wrote:
> 
>>
>>> outreg2 lrwage lrwager firm_l firm_iqr [Self0 Self1 ...]
>>> using myfile_`y', replace bdec(2) label nocons excel}
>>>
>>> file myfile_happ.txt is read-only; cannot be modified or erased
>>> dr(608)
>>>
>>> And I get this error whether myfile_happ.txt exists in the directory
>>> or not.
>>
>> You usually get this error when the file is being used by another  
>> software,
>> usually Excel or Word. This happens when you peek at the output while
>> -outreg2- is still running. This makes the file "read-only" to Stata.
>>
>> The solution is to close the file and don't open it until Stata has
>> finished running. Because Adrian's problem is intermittent, this might
>> be the case.
>>
>> If you want to look at an -outreg2- file while it is still running,  
>> then
>> you should copy-and-paste the file (control-c, control-v), and then  
>> look
>> at the duplicated file.
>>
>> I think this is mentioned somewhere in the help file (not leave the  
>> file
>> open), but a smart thing is for -outreg2- to send its own error  
>> message
>> telling you to close the file.
>>
>> If this cannot be done, then it needs to be put in the help file
>>
>> Roy
>>
>> _________________________________________________________________
>> Hotmail® has a new way to see what's up with your friends.
>> http://windowslive.com/Tutorial/Hotmail/WhatsNew?ocid=TXT_TAGLM_WL_HM_Tutorial_WhatsNew1_052009
>> *
>> *   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/

_________________________________________________________________
Windows Live™: Keep your life in sync.
http://windowslive.com/explore?ocid=TXT_TAGLM_BR_life_in_synch_052009
*
*   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/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index