Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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


foreach v of var k* {
       local V : subinstr local v "k" ""
       <stuff using `V'>


On Sat, Dec 1, 2012 at 10:34 AM, Mahbubeh Parsaeian
<> 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:

© Copyright 1996–2017 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index