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 on April 23, and its replacement, statalist.org is already up and running.


[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 <njcoxstata@gmail.com>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
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
njcoxstata@gmail.com

On 25 June 2013 20:03, Miguel Angel Duran Munoz <maduran@uma.es> 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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index