Statalist The Stata Listserver


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

st: Re: Can a global macroname act as a prefix?


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
Subject   st: Re: Can a global macroname act as a prefix?
Date   Tue, 08 May 2007 08:28:32 -0400

You need to put braces {} around global names so Stata can tell where they end -- local don't have this problem because they include `' to enclose the full name.

Michael Blasnik

----- Original Message ----- From: "Steven Samuels" <[email protected]>
To: <[email protected]>
Sent: Tuesday, May 08, 2007 8:07 AM
Subject: st: Can a global macroname act as a prefix?



Local variables can act as prefixes and suffixes in variable names:

local a = "local"
gen `a'_x = 1 // create local_x
gen x_`a'= 1 // creates x_local

global b= "global"
gen x_$b= 1 // creates x_global

gen $b`a'= 1 // creates globallocal

My question: Can I create something a variable named "global_x" using the global variable $b ?
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   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