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

From |
Nick Winter <nwinter@virginia.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: comment out a number of lines together |

Date |
Tue, 30 Sep 2008 16:46:29 -0400 |

Hi,

No one has mentioned--unless I missed it--that multiple lines of code can be commented out with /* and */. So in this code

a

b

/*

c

d

e

f

*/

g

h

lines c,d, e and f will all be skipped.

-Nick Winter

Sergiy Radyakin wrote:

Nick, local c // will not work in the program because "//" is interpreted as the start of the comment it works in the command line though, because "//"-style comments are prohibited in the command line input. To fix this: 1) open quotes before // like so: local c "//" , or 2) write it down as an expression, e.g. local c="/"+"/" In any case, Stata fails to recognize "//" as a comment when it comes as a result of macro expansion. But it works for a star ("*"). // --- begin of file testc.do --- local c // display `"`c'"' local c ="/"+"/" display `"`c'"' local c "//" display `"`c'"' local c "*" display `"`c'"' `c' just nothing local c "//" `c' just nothing // --- end of file testc.do --- If writing out debugging messages, it may be more comfortable to use di_g. See: help di_g. Best regards, Sergiy Radyakin On Tue, Sep 30, 2008 at 11:28 AM, Nick Cox <n.j.cox@stata.com> 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 n.j.cox@durham.ac.uk Maarten buis wrote:--- Paul O'Brien <paul.obrien@afe2.org.uk> 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/* * 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/

-- -------------------------------------------------------------- Nicholas Winter 434.924.6994 t Assistant Professor 434.924.3359 f Department of Politics nwinter@virginia.edu e University of Virginia faculty.virginia.edu/nwinter w PO Box 400787, 100 Cabell Hall Charlottesville, VA 22904 * * 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/

**References**:**Re: st: comment out a number of lines together***From:*Maarten buis <maartenbuis@yahoo.co.uk>

**Re: st: comment out a number of lines together***From:*Nick Cox <n.j.cox@stata.com>

**Re: st: comment out a number of lines together***From:*"Sergiy Radyakin" <serjradyakin@gmail.com>

- Prev by Date:
**st: IIA test after svy:mlogit** - Next by Date:
**st: Re: labeling estout models with titles from eststo** - Previous by thread:
**Re: st: comment out a number of lines together** - Next by thread:
**Re: st: comment out a number of lines together** - Index(es):

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