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: How to drop variables with odd-numbered varname-suffix


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: How to drop variables with odd-numbered varname-suffix
Date   Fri, 4 Mar 2011 18:03:07 +0000

foreach v of var * {
       if mod(real(substr("`v'",-1,1)), 2) == 1 drop `v'
}

Nick

On Fri, Mar 4, 2011 at 5:54 PM, Ben Ammar <[email protected]> wrote:
>
> one quick question: How can I drop variables whose varname ends with an odd number (household1  household3   household5)?
> I know how to drop odd-numbered observations but unfortunately not how to delete the variable with an odd-numbered suffix itself?

*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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