Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

st: Re: Declaring several local variables at once


From   Dani Tilley <tilleydani@yahoo.com>
To   stata <statalist@hsphsun2.harvard.edu>
Subject   st: Re: Declaring several local variables at once
Date   Thu, 5 Aug 2010 11:12:35 -0700 (PDT)

Thanks Nick. 

----- Original Message ----

You don't declare local macros in advance. You just define them as
needed.

local a b c = 0

is legal but if defines the local macro -a- as the text "b c = 0", which
is not what you want. Trying to -display- that does cause a problem for
separate reasons.

local a = 0
local b = 0
local c = 0

is the easiest way to do it, short of messing around with command
delimiters.

Locals disappear when a program ends; that's part of their definition.

Nick
n.j.cox@durham.ac.uk



From: Dani Tilley <tilleydani@yahoo.com>
To: stata <statalist@hsphsun2.harvard.edu>
Sent: Thu, August 5, 2010 2:06:29 PM
Subject: Re: Declaring several local variables at once

Thanks for your reply. So, is there a way to declare them in one line that 
avoids this?
----- Original Message ----
<>

-local-s tend to vanish once the -program- stops anyway, but you can of
course -macro drop _all- should you so wish...

Stata thinks your -local- "a" contains the string "b c=0", btw:

***
loc a b c=0
di "`a'"
***


HTH
Martin


From: Dani Tilley <tilleydani@yahoo.com>
To: stata <statalist@hsphsun2.harvard.edu>
Sent: Thu, August 5, 2010 1:59:03 PM
Subject: Declaring several local variables at once

Hi,

I was wondering how you can declare more than one local var in one line.

I tried -loc a b c=0- and it returned no error. But -di `a'- returned r(111). 
Also, is there a way to `drop' the locals after your program ends?

Thanks in advance.

DF Tilley


      

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index