Statalist The Stata Listserver


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

Re: st: RE: fine tuning do files


From   David Kantor <[email protected]>
To   [email protected]
Subject   Re: st: RE: fine tuning do files
Date   Mon, 30 Oct 2006 11:58:39 -0500

At 11:30 AM 10/30/2006, Nick Cox wrote:
[...]

On 2), do files can have arguments.
[...]
I might add that do files can also have -syntax-, though I suppose that -syntax- was not intended to be used that way. And you cannot use options in this situation, as any options you write in the command will be picked up as options to -do- (or -run-), and not passed on to the do file. So, you probably never would want to do this, but it's interesting to know of the possibility.


[...]
I ignored the idea of interaction with the program
in the sense of the program asking a question. You
can do it, as documented at [P] display or in
the corresponding help, but it's not Stataish.
[...]
Yes, it is very rare, in my experience, to write code that interacts with the user. I've done it maybe 3 times in all my years of Stata use, and it's always been very simple queries. Here's an example, from the very end of a do-file:

capture save products
if _rc==602 {
disp "File exists. Replace? " _req(yn)
if upper("$yn") == "Y" {
save products, replace
}
else {
disp "file not replaced"
}
}

I hope this is helpful or interesting.
--David

*
* 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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index