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   Sun, 6 Mar 2011 10:20:13 +0000

drop *1 *3 *5 *7 *9

trumps that solution for brevity. Those who dislike brute force
solutions which grind through all the possibilities will note that
here grinding through all the possibilities is still very concise
(until someone else suggests a better solution).

Nick

On Fri, Mar 4, 2011 at 6:03 PM, Nick Cox <[email protected]> wrote:
> 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