[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
Re: st: Macro from scalar
From
Nick Winter <[email protected]>
To
[email protected]
Subject
Re: st: Macro from scalar
Date
Fri, 22 Aug 2008 15:07:13 -0400
Note the difference between:
scalar s = 1
local l s
and
scalar s = 1
local l = s
in the first case, the string "s" is put in local l. When you display
`l', Stata replaces `l' with the string "s", which is then evaluated as
a scalar.
In the second case, the local l is given the (current) value of the
scalar s.
Which you want depends on whether you want the value you get when you
refer to the local to change when the scalar changes. Consider:
. scalar s = 1
. local m1 s
. local m2 = s
. scalar s = 2
. di `m1'
2
. di `m2'
1
--Nick Winter
Eva Poen wrote:
Douglas,
like this?
scalar s = 1
local l s
di s
di `l'
To avoid confusion with variable names, you can write
local l scalar(s)
Hope this helps,
Eva
2008/8/22 Levy, Douglas E., Ph.D. <[email protected]>:
Hi all,
Is there a way to take a scalar and place its value in a macro?
Thanks,
Doug
Douglas Levy, PhD
Institute for Health Policy
Massachusetts General Hospital
50 Staniford Street; Suite 901
Boston, MA 02114
Tel 617.643.3595
Fax 617.724.4738
*
* 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
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/
© Copyright 1996–2024 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |