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 at the end of May, 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   daniel klein <klein.daniel.81@gmail.com>
To   statalist@hsphsun2.harvard.edu
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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index