In addition to Scott Merryman's post, I'll
observe that indicator questions are often
easier flipped the other way up, just like
probability questions.
Positively, Clive is happy with
conch < . & edconch < . & marker != 0
and so
gen mark = conch < . & edconch < . & marker != 0
should be close to the mark.
Nick
[email protected]
Clive Nicholas
> I'm trying to -egen-erate a dummy variable which 'marks off'
> cases in my
> dataset which are both (1) missing on two key variables and
> (2) have been
> already been coded 0 as duplicate cases by an -egen,
> tag()-ged variable
> called -marker-. I want the generated variable (-mark-) to
> look like this:
>
> +-----------------------------------------------+
> | pano conch edconch marker mark |
> |-----------------------------------------------|
> 1600. | 436 2.08482 1.042244 1 1 |
> 1601. | 436 -2.551552 -23.68557 0 0 |
> 1602. | 436 1.171085 -18.44246 0 0 |
> 1603. | 436 -2.551552 -28.24039 0 0 |
> 1604. | 436 1.171085 -23.11701 0 0 |
> |-----------------------------------------------|
> 1605. | 436 9.708897 -6.17593 0 0 |
> 1606. | 436 9.708897 -9.517298 0 0 |
> 1607. | 437 -2.786781 . 1 0 |
> 1608. | 437 -.6094589 . 1 0 |
> 1609. | 437 -12.96428 . 1 0 |
> |-----------------------------------------------|
> 1610. | 437 1.095558 . 1 0 |
> 1611. | 438 7.136993 21.97673 1 1 |
> 1612. | 438 .5475883 5.041264 1 1 |
> 1613. | 438 2.488335 .6113586 1 1 |
> 1614. | 438 -6.498318 -11.1867 1 1 |
> |-----------------------------------------------|
> 1615. | 438 .7604446 21.50825 1 1 |
> 1616. | 439 6.331062 1.482658 1 1 |
> 1617. | 439 -1.661823 -11.79961 1 1 |
> 1618. | 439 2.188976 -3.028099 1 1 |
> 1619. | 439 -6.502392 -17.35701 1 1 |
> |-----------------------------------------------|
> 1620. | 439 3.512476 8.189182 1 1 |
> +-----------------------------------------------+
>
> As you can see, -mark- is 0 when _either_ -conch- or
> -edconch- is missing
> _or_ when -marker- is 0 (or, indeed, both). I thought this
> would be a dead
> simple task (perhaps it really is), but all the commands I've
> issued so
> far aren't executing what I want. For example:
>
> (1) Trying to do it in two:
>
> gen mark=0 if conch!=. & edconch!=. & marker==1
> recode mark .=1
>
> (2) Trying to do it step-by-step:
>
> gen mark=0 if marker==0
> replace mark=0 & conch==.
> replace mark=0 if edconch==.
> replace mark=1 if marker==1
> replace mark=1 & conch!=.
> replace mark=1 if edconch!=.
>
> (3) Using -egen- functions (admittedly, partly out of desperation):
>
> egen mark=eqany(conch edconch) if marker==1 & conch!=. //
> & edconch!=., values(-100/100)
>
*
* 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/