Bookmark and Share

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

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

Re: st: assign several lines of syntax to local?

From   Nick Winter <>
Subject   Re: st: assign several lines of syntax to local?
Date   Thu, 12 Aug 2010 09:34:54 -0400

Your first example will work if the contents of the local are not enclosed in quotes:

. local a foo ///
>         bar

. di "[`a']"
[foo         bar]

or you can do:

. local a "foo " ///

if for some reason you need to enclose the local in quotation marks.

- Nick Winter

On 8/12/2010 5:59 AM, Maarten buis wrote:
--- On Thu, 12/8/10, raoul reulen wrote:
I have a large do-file in which a few lines of syntax come
back several times. It is possible to assign a local to the
lines of syntax so that I don't have to repeat it all the
time?<snip>  So, essentially I would like to assign several
lines of syntax to a local, is this possible?

I am guessing that the problem is that you don't want to list
all the options on one line, because then that line would get
too long to be (easily) readable, and that a statement like

local a "foo  ///

doesn't work, as Stata considers the -///- as part of the string
and not as an indication that it needs to move to the next line.

In that case you can temporarily change the delmiter to -;-,
using the -#delimit- command, like in the example below:

*------------ begin example ------------
sysuse auto

#delimit ;
local opts vce(robust)
            beta ;
#delimit cr
reg price mpg, `opts'
*------------ end example --------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Institut fuer Soziologie
Universitaet Tuebingen
Wilhelmstrasse 36
72074 Tuebingen

*   For searches and help try:

Nicholas Winter                                 434.924.6994 t
Assistant Professor                             434.924.3359 f
Department of Politics         e
University of Virginia w
S385 Gibson Hall, South Lawn
*   For searches and help try:

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