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

st: RE: question about substracting a part of a string in a dummy variab


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: question about substracting a part of a string in a dummy variab
Date   Mon, 7 Nov 2005 16:21:49 -0000

gen byte wheretheactionis = strpos(myvar, "action") > 0 

or in Stata < 9 

gen byte wheretheactionis = index(myvar, "action") > 0 

Nick 
[email protected] 

Erik Brouwer
 
> I have a question. I have a string variable containing a 
> short description 
> (3 till 5 words per observation). What I would like to do is 
> to make a dummy 
> which equals 1 if the string variable contains the word 
> "action".  The word 
> "action" is not allways on the same place. Can someone help me?

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index