[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]
st: RE: RE: regexm()
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?
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
> 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: