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: assign several lines of syntax to local?


From   Nick Winter <[email protected]>
To   [email protected]
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 " ///
	"bar"

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  ///
          bar"

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:
http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

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

http://www.maartenbuis.nl
--------------------------




*
*   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                  [email protected] e
University of Virginia          faculty.virginia.edu/nwinter w
S385 Gibson Hall, South Lawn
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index