Statalist


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

st: Fwd: problem with regexm


From   "Yun Liu" <liuyun3@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: Fwd: problem with regexm
Date   Tue, 15 Jul 2008 17:50:39 -0400

Hi,

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!

Yun
*
*   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