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


[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 <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
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
<mahbobehparsaeian@yahoo.com> 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/


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