Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: -capture noisily- shorthand


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: -capture noisily- shorthand
Date   Mon, 14 Jan 2013 12:52:23 +0000

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 <[email protected]> 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 <[email protected]> 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 <[email protected]> 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
>>
>> *
>>
>> *   For searches and help try:
>> *   http://www.stata.com/help.cgi?search
>> *   http://www.stata.com/support/faqs/resources/statalist-faq/
>> *   http://www.ats.ucla.edu/stat/stata/
>
>
>
> --
> Patrick Toche.
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index