Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: RE: regexm()


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: regexm()
Date   Wed, 19 Oct 2005 18:34:40 +0100

Regular expressions are not the first thing to try. 

gen mentions_drug = strpos(drug, "drugname") > 0 

or in Stata < 9 

gen mentions_drug = index(drug, "drugname") > 0 

is what I would try. This is also relevant: 

FAQ     . . . . . . . . . . . . . . . . . . . . . . .  True and false in Stata
        2/03    What is true and false in Stata?
                http://www.stata.com/support/faqs/data/trueorfalse.html

A Google on regular expressions reveals numerous 
sources. Any moderately detailed guide to Unix 
will contain a tutorial chapter and will be informative
even if your OS emanates from Redmond, WA. 

Documenting its support for regular expressions 
a little more fully is, or in my view should be, 
on the StataCorp agenda. Previous threads on 
regular expressions have underlined that there 
is also user interest in writing about them 
in Stata. 

Nick 
n.j.cox@durham.ac.uk 

Terra Curtis
 
>  I am tring to use a combination of string functions to perform the
> following.  I have a variable called drug which includes, for example,
> something like "drugname" and "drugname capsules" and 
> "drugname inhaler",
> etc.  I want to set a dummy variable equal to 1 when 
> drug=="drugname" or any
> part of the string drug =="drugname."  I think -regexm- might 
> be on the
> right track, but I'm not sure exactly what is meant by a 'regular
> expression.'  Suggestions?
 

*
*   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