Statalist


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

Re: st: comment out a number of lines together


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: comment out a number of lines together
Date   Tue, 30 Sep 2008 13:18:25 -0500

I think Stata is picking up some other syntax error in your command.
My suggestion still looks good to me. Check out whether local macro dur 
is defined to be something suitable.

. sysuse auto

. local c *

. `c' regress mpg

. local c

. `c' regress mpg

       Source |       SS       df       MS              Number of obs = 
      74
-------------+------------------------------           F(  0,    73) = 
   0.00
        Model |           0     0           .           Prob > F      = 
       .
     Residual |  2443.45946    73  33.4720474           R-squared     = 
  0.0000
-------------+------------------------------           Adj R-squared = 
0.0000
        Total |  2443.45946    73  33.4720474           Root MSE      = 
  5.7855

------------------------------------------------------------------------------
          mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. 
Interval]
-------------+----------------------------------------------------------------
        _cons |    21.2973   .6725511    31.67   0.000      19.9569 
22.63769
------------------------------------------------------------------------------

Nick
[email protected]

paul o'brien wrote:

> thank everyone.
> on nick's suggestion:
> 
> . local c *
> . `c' metan p np p2 np2 if dur==`dur'
> . [command ignored - fine]
> 
> . local c
> . `c' metan p np p2 np2 if dur==`dur'
> invalid syntax
> r(198);
> 
> 'local c' is not interpreted as empty with `c' placed before the
> command. if the macro is zapped i have to remove the `c' on each line
> which defeats the object. am i doing it right?
> 
> paul
> 
> 
> On 30/09/2008, Nick Cox <[email protected]> wrote:
>> Another is to prefix lines by e.g.
>>
>> `c'
>>
>> Setting
>>
>> local c *
>>
>> or
>>
>> local c //
>>
>> comments out those lines.
>>
>> Setting
>>
>> local c
>>
>> zaps the macro.
>>
>> Naturally any definition of the local as "*" or "//" must precede all uses that require that interpretation.
>>
>> The converse does not apply: if the local is not defined, Stata sees the line.
>>
>> More generally, you can define or undefine the macro at will.
>>
>> I don't especially recommend this method, but it is an alternative that is sometimes useful, and it matches practices in many programming languages.
>>
>> Nick
>> [email protected]
>>
>>
>> Maarten buis wrote:
>>
>>> --- Paul O'Brien <[email protected]> wrote:
>>>
>>>
>>>> at times i need to comment out a number of lines, usually with * and remove the * later to activate the commands.
>>>> is there a simple way to remove and add the * to a number of line at one go?
>>>>
>>> One way to comment out a block of code is to surround them with /* and
>>> */ this way you have to remove only these two.


*
*   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