But that will work only as a prefix to single-line commands.
that's a good start anyhow,
thanks a lot Nick!
Patrick.
----
Patrick Toche
On Mon, 14 Jan 2013 20:52:23 +0800, Nick Cox <njcoxstata@gmail.com> wrote:
You could write your own program -cn-. I am not encouraging you to do
so, but it's simple.
program cn
* no version number
capture noisily `0'
end
Nick
On Mon, Jan 14, 2013 at 12:47 PM, annoporci <annoporci@gmail.com> wrote:
In practice, experienced Stata programmers don't use them
In practice, I would use a local macro for this purpose.
Thanks Nick, will do!
I see no case for allowing the abbreviated command -cn-, as it is too
cryptic.
yes, it sort of sounds a little bit like a shorthand for "China" (which
is
where I live by the way).
Thanks Nick for your instant reply,
Patrick.
----
Patrick Toche.
On Mon, 14 Jan 2013 20:35:38 +0800, Nick Cox <njcoxstata@gmail.com>
wrote:
The problem with global macros is that this definition might clash
with other definitions used in other programs.
In practice, experienced Stata programmers don't use them unless
really needed, for precisely this reason, so your main risk is that
you forget about this definition when also using different code of
your own.
In practice, I would use a local macro for this purpose. This is more
a matter of style than anything else.
I see no case for allowing the abbreviated command -cn-, as it is too
cryptic.
Nick
On Mon, Jan 14, 2013 at 12:27 PM, annoporci <annoporci@gmail.com>
wrote:
I want to systematically use -capture noisily- throughout a do-file
with
multiple loops (as some fail).
The shortest form for it is -cap n-
Not bad. However, I thought it would be neater to have something even
shorter, say -cn-. Unfortunately that's an "unrecognized command"
(implemented in a future version of Stata maybe?)
I defined a macro to store "capture noisily" and repeatedly use the
macro.
See the example code below.
I used a "global" macro so that I could use the dollar sign in front
of
it
-- easy to type and remember.
The trick seems to work, but is it an acceptable practice? any
pitfalls?
many thanks.
--
Patrick Toche.
/// Different ways of preceding a command with -capture noisily-
clear all
sysuse auto
capture noisily regress price mpg rep78
cap n reg price mpg rep78
cap n reg price mpg rep79
global cn "capture noisily"
$cn reg price mpg rep78
$cn reg price mpg rep79
regress price mpg rep78