Bookmark and Share

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]

st: Re: finding a word within a string variable in Stata 12


From   Nick Cox <[email protected]>
To   [email protected]
Subject   st: Re: finding a word within a string variable in Stata 12
Date   Wed, 21 Mar 2012 20:21:46 +0000

I haven't tried to see what doesn't work with the regex machinery
because this problem seems to call only for

gen construction = strpos(sic, "construction") > 0

Nick

On Wed, Mar 21, 2012 at 7:28 PM, Navarro Paniagua, Maria
<[email protected]> wrote:
> Dear Professor Cox,
>
>
>
> I am trying to find a word (for instance construction) within a string
> variable (sic), the string can have as categories (construction 1, b
> construction)
>
>
>
> Could you please help me with this?
>
>
>
> gen construction = regexs(1) if regexm(sic, "[construction]+")
>
> g one = 1 if strmatch(sic, "*constr*")
>
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index