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: operations on macro elements


From   Phil Clayton <[email protected]>
To   [email protected]
Subject   Re: st: operations on macro elements
Date   Wed, 16 May 2012 23:03:10 +1000

In general I can't think of a good reason why you'd want to avoid extended functions. They're:
- very powerful
- well documented
- (generally) easy to use

That said, you don't need them here:
local x a b c
foreach word in `x' {
	local y `y' `word'_1
}
di "`y'"

The above assumes that the macro `y' is not already defined. If it is, you'd first need to clear it with -local y-

Phil

On 16/05/2012, at 10:41 PM, Abhimanyu Arora wrote:

> Dear statalist
> I have a macro say, x containing the string  "a b c"
> I would like to have a macro y such that y contains the string "a_1
> b_1 c_1" ? Is there a simple way using sort of extended functions?
> Many thanks
> Cheers
> Abhimanyu
> *
> *   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/


*
*   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