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, is already up and running.

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

Re: st: Adding a suffix to variables in a local macro

From   Nick Cox <>
To   "" <>
Subject   Re: st: Adding a suffix to variables in a local macro
Date   Sun, 9 Jun 2013 17:43:42 +0100

local commod2 : subinstr local commod " " "98 ", all

local commod3 : subinstr local commod2 "98" "99", all

Such trickery in this kind of context  is also documented at
-- not that I expect anyone apart from me to know or remember that.

Search for "unab" in that FAQ.


On 9 June 2013 17:37, G. Anderson <> wrote:
> I have a large list of variables, from which I have created a local macro:
> local commod tea coffee sugar wheat
> I also have variables in my data set, which refer to specific years, so I
> have variables tea98, coffee98, sugar98, wheat98 etc
> I would like to create a local macro referring to each year, so:
> local commod98 tea98 coffee98 sugar98 wheat98
> local commod99 tea99 coffee99 sugar99 wheat 99
> etc.
> Is there a way to do this, referring to local commod and adding the the
> suffix "98" "99" etc?
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index