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" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
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 
n.j.cox@durham.ac.uk 

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