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   daniel klein <>
Subject   Re: st: storing part of variable names in a list
Date   Sat, 1 Dec 2012 12:28:00 +0100

Is this the structure of your real dataset? If so, the numerical part
of a variable name starts at the second position. This puts the
numerical part of the variables into local macro <numnames>:

unab vars : *
foreach v of loc vars {
    loc numnames `numnames' `= substr("`v'", 2, .)'
di "`numnames'"

If this is what you want, fine. If not, it would help if you gave us
an idea of where you are going with this?

Hi statistician
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