Bookmark and Share

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   daniel klein <[email protected]>
To   [email protected]
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?

Best
Daniel
-- 
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:
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index