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]

Re: st: indicator for "if cell contains the word or phrase"


From   Shehzad Ali <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: indicator for "if cell contains the word or phrase"
Date   Sun, 16 Sep 2012 19:27:16 +0100 (BST)

Thanks, Nick. As always, your advice is spot on and very helpful!

Many thanks
Shehzad



----- Original Message -----
> From: Nick Cox <[email protected]>
> To: "[email protected]" <[email protected]>
> Cc: 
> Sent: Sunday, 16 September 2012, 16:05
> Subject: Re: st: indicator for "if cell contains the word or phrase"
> 
> . gen stuff_present =  strpos(strvar, "stuff") > 0
> 
> For a case-insensitive match compare "stuff" with -lower(strvar)-.
> 
> Nick
> 
> On 16 Sep 2012, at 15:44, Shehzad Ali <[email protected]> wrote:
>> 
>>  I have a variable var1 that describes various situations in the form of 
> long description. I want to generate a dummy variable var2 equal to 1 if var1 
> contains a certain word 'xyz' or phrase. var1 may contain other words 
> but I want to check if xyz or a certain phrase appears in the cell or not.
>> 
>> 
> *
> *   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/


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