Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Re: global keys


From   Brendan Halpin <brendan.halpin@ul.ie>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Re: global keys
Date   Wed, 19 Sep 2007 13:25:36 +0100

"Michael Blasnik" <michael.blasnik@verizon.net> writes:

> ----- Original Message ----- 
> From: "Michael McCulloch" <mm@pinest.org>
>> Is there a less labor-intensive way to do the following:
>>
>> keep if site_02=="C180" |  site_02=="C181" |  site_02=="C182" |  ///
>> site_02=="C183" |  site_02=="C184" |  site_02=="C185" | ///
>> site_02=="C186" |  site_02=="C187" |  site_02=="C188" |
>> site_02=="C189"

> see help inlist()
>
> It only works with up to 10 strings (which your example exactly meets)

Or use regular expressions:

. keep if regexm(site_02,"C18[0-9]")

Brendan
-- 
Brendan Halpin,  Department of Sociology,  University of Limerick,  Ireland
Tel: w +353-61-213147 f +353-61-202569 h +353-61-338562; Room F2-025 x 3147
mailto:brendan.halpin@ul.ie  http://www.ul.ie/sociology/brendan.halpin.html
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index