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: only keep obs of determinate string length
From
Steve Nakoneshny <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: only keep obs of determinate string length
Date
Wed, 30 Jan 2013 11:02:00 -0700
A perfect (and speedy!) solution! Thanks Rich and Nick.
On 2013-01-30, at 10:56 AM, Nick Cox wrote:
> Typo time
>
> keep if inrange(length(varname),11,12)
>
> Nick
>
> On Wed, Jan 30, 2013 at 5:51 PM, Richard Goldstein
> <[email protected]> wrote:
>
>> try this
>>
>> keep if inrange(length(varname,11,12))
>
> On 1/30/13 12:47 PM, Steve Nakoneshny wrote:
>
>>> I have a unique string id var. Values in this var vary from 8-16 characters in length.
>> I only want to keep obs where the length of the id string is either 11
>> or 12 characters
>> long. I know I can solve this in a more cumbersome manner using the
>> -regex- machinery,
>> but I was hoping for a more succinct solution using string functions.
> *
> * 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/
*
* 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/