Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: RE: Fwd: problem with regexm


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: Fwd: problem with regexm
Date   Wed, 16 Jul 2008 17:19:37 +0100

-regexm()- is a function, not a command. 

On the face of it this looks alarming. 

I tried out variations on -regexm("", "CEO")- and got 0 every time. So I
can't reproduce this problem. 

Did you do anything else after the -generate-? 

Nick
n.j.cox@durham.ac.uk 

Yun Liu

I encounter a weird problem when using the regexm command. I want to
recoganize "CEO" from a job title variable, B. Note there are many
missing values in B. Here is the command I use:
gen Bh=regexm(B, "CEO")

However, for some missing Bs, it returns zero for Bh. See below:

. list B Bh in 28107/28110

      +----------------+
      |         B   Bh |
      |----------------|
28107. |              1 |
28108. |              1 |
28109. | President    0 |
28110. | Senior VP    0 |
      +----------------+

. count if B=="" & Bh==1
  63
. count if B=="" & Bh==0
 6186
. replace Bh=regexm(B, "CEO") if B=="" & Bh==1
(63 real changes made)
. count if B=="" & Bh==1
   0

What did I do wrong? Could you please help me out? Thank you!


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