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: storing part of variable names in a list
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: storing part of variable names in a list
Date
Sat, 1 Dec 2012 11:18:40 +0000
The FAQ explains (twice!) that you should not start a new thread in
this way. e.g "please do not start a new thread by replying to a
previous posting. Again even if you delete the previous posting’s
contents and change its title, such practice messes up archiving"
unab klist : k*
local klist : subinstr local klist "k" "", all
or
foreach v of var k* {
local V : subinstr local v "k" ""
<stuff using `V'>
}
Nick
On Sat, Dec 1, 2012 at 10:34 AM, Mahbubeh Parsaeian
<[email protected]> wrote:
> I have a dataset with these variables
> k1 k21 k35 k41 k57 k69 p1 p21 p35 p41 p57 p69
> I know, If I want to store these variable names and use these names in a
> loop I can use unab
> But I need a function that store just the numbers not all the name and
> then I can write a loop for these numbers.
> Would you please help me to find a suitable answer?
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/