Statalist


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

Re: st: simple question


From   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: simple question
Date   Tue, 5 Feb 2008 13:11:05 +0100

Renuka Metcalfe wrote:

I want to create a dummy variable redundism which
equals dummy = 1 if the establishment has had any
dismissals or redundancies in the past 12 months. I
would be grateful, if anyone would let me know if the
following is the correct way to do it. There is a
debate amongst us at whether it in the second line it
should be "|" or "&". I would be grateful, if you
would confirm if the following is correct or should it
be an "&"

ge redundism=.
replace redundism=1 if zredundab==1|zdismissa==1
replace redundism=0 if zredundab==0|zdismissa==0

-----------------------------------------------------------

By your description it is an OR, i.e. "�". However,
the sequence of the two -replace- commands is wrong.
Now it gives this result:

. input zredundab zdismissa

     zredundab  zdismissa
  1. 0 0
  2. 0 1
  3. 1 0
  4. 1 1
  5. end

. ge redundism=.
(4 missing values generated)

. replace redundism=1 if zredundab==1|zdismissa==1
(3 real changes made)

. replace redundism=0 if zredundab==0|zdismissa==0
(3 real changes made)

. list

     +--------------------------------+
     | zredun~b   zdismi~a   redund~m |
     |--------------------------------|
  1. |        0          0          0 |
  2. |        0          1          0 |
  3. |        1          0          0 |
  4. |        1          1          1 |
     +--------------------------------+


Try swithching the two -replace- commands.

Hope this helps
Svend
______________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone:   +45 8942 6090
Mobile:  +45 2634 7796
Email:   [email protected]
__________________________________________ 

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