Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Stepping through do file


From   "Buzz Burhans" <buzzb3@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Stepping through do file
Date   Sat, 29 Mar 2008 20:25:25 -0400

Michael, 

-addpause- works very well.  It advances the -do- file execution a few lines
and allows me to check the data at every pause -Nice!

I have tried to modify it to do two additional things, but I have not been
able to succeed:

I tried to add a line number to the added pause when each is written, but I
must be missing something because I could not get it do so. (I tried to use
the content of `lnum' and _n after the "pause".)  When I previously added
the pauses manually I added them as:

"pause L10" or Lxxx

When the pause occurred this allowed me to see where (line number) I was
pausing and find the section of the script in the -do-file prior to that
pause.

The other thing I tried to do was add a " ,replace" to the creation of the
new file with the "_pause"  suffix.

These are not big problems, but if you could look at if they could be added
to your -addpause- without much effort I would be very grateful.

Once this thread is in the archives I'm glad others will be able find your
code for -addpause- -it is a great help in addressing the problem I started
the thread with of stepping through a -do- file.

If StataCorp is listening, it would be a great advantage to be able to open
a -do- file in the -do- file editor and "step" through it. It is problematic
to step through highlighted lines in the editor because the temps and macros
are lost when only blocks of code are run from a longer -do-file.

Thanks Michael.  Your -addpause- utility is very helpful!

Buzz

Buzz Burhans, Ph.D.

Dairy-Tech Group

Twin Falls, ID
Phone: 208-320-0829
Fax: 208-735-1289 

So. Albany VT
Phone: 802-755-6842

Email: buzzb3@verizon.net

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Michael Blasnik
Sent: Saturday, March 29, 2008 1:11 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: Stepping through do file

It might be better to just be able to quickly edit your do files to add
-pause- 
every other line (or every 3 lines or 4 lines etc..), which is what
addpause.ado 
does.  By default it creates a new do file that just appends _pause" to the 
original file name.  So you can adjust your original do file and then just
run 
addpause to create the pausing version for testing.

program define addpause
version 9.1
syntax using/, [every(integer 1) saving(str) ]
tempname hdl new
if "`saving'"=="" {
 local saving: subinstr local using ".do" "_pause.do"
}
file open `new' using `"`saving'"', write text replace
file open `hdl' using `"`using'"', read  text
file read `hdl' line
local lnum=1
while r(eof)==0 {
 file write `new' `"`macval(line)'"' _n
 if mod(`lnum',`every')==0 {
  file write `new' "pause" _n
 }
 file read `hdl' line
 local lnum=`lnum'+1
}
file close `hdl'
file close `new'
di "New do file created: `saving'"
end

Good Luck,

Michael Blasnik


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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