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: Drop depending of the first digits of a variable


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Drop depending of the first digits of a variable
Date   Tue, 25 Jun 2013 20:09:42 +0100

If the variable is numeric

drop if substr(string(myvar), 1, 2) == "65"

or

drop if floor(myvar/100) == 65

and if it is string

drop if substr(myvar, 1, 2) == "65"

Nick
[email protected]

On 25 June 2013 20:03, Miguel Angel Duran Munoz <[email protected]> wrote:

>  I have a variable whose observations are identified by a
> four-digit number (eg, 5434, 6576...). I would like to drop those
> observations whose first two digits are 65 (eg, drop 6576 but keep 5434).
*
*   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