Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Seyi Soremekun" <Seyi.Soremekun@lshtm.ac.uk> |
To | <statalist@hsphsun2.harvard.edu> |
Subject | Re: st: reading dataset if (Away) |
Date | Wed, 21 Sep 2011 23:49:15 +0100 |
I am away from the 21st September until the 12th October. Please direct any urgent enquiries to Linda Vesel (linda.vesel@lshtm.ac.uk). Seyi >>> Austin Nichols <austinnichols@gmail.com> 09/21/11 23:48 >>> Emmanuelle Lavaine <Emmanuelle.Lavaine@univ-paris1.fr>: Try use if inlist(substr(diagp,1,1), "I", "J") using dataset.dta On Wed, Sep 21, 2011 at 6:12 PM, Nick Cox <njcoxstata@gmail.com> wrote: > You are reaching towards some kind of regular expression test but == > is a test for equality. > > use dataset.dta if inlist(substr(diagp,1,1), "I", "J") > > use dataset.dta if substr(diagp,1,1) == "I" | substr(diagp,1,1) == "J" > > Regular expressions are also possible here: > > . di regexm("Janvier", "^[IJ]") > 1 > > . di regexm("jeunesse", "^[IJ]") > 0 > > . di regexm("Jeunesse", "^[IJ]") > 1 > > use dataset.dta if regexm(diagp, "^[IJ]") > > On Wed, Sep 21, 2011 at 10:46 PM, Emmanuelle Lavaine > <Emmanuelle.Lavaine@univ-paris1.fr> wrote: > >> I have a huge dataset and I would like to get rid of some observations >> when opening it. >> I want to open my dataset only if the first character corresponds to >> 'I' or 'J' >> for the string variable 'diagp', I have something like: >> >> diagp >> I236 >> I256 >> I52 >> J46 >> J856 >> H343 >> etc.. >> >> I tried: >> use 'dataset.dta' if diagp=="[I-J]*" >> >> But I am doing something wrong and I can't figurate it out. > * * 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/ * * 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/