Statalist


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

st: RE: Replacing values within a matched study


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: Replacing values within a matched study
Date   Wed, 28 May 2008 12:57:30 +0100

bysort groupid (breast) : replace breast = 0 if control == 1 & breast[1]
== 1 

bysort groupid (colon) : replace colon = 0 if control == 1 & colon[1] ==
1

looks sufficient from your example. 

Nada Khan

I have a matched case control dataset with patients who have had breast,
colon or prostate cancer with 4 matched controls each and a matching
variable (groupid).  My data looks like this:

id    groupid     breast    colon    prostate  control
1        1              1            .              .             .
2        1              .            .               .             1
3        1              .             .              .             1
4        1              .             .               .            1
.
.
.
89     40             .             1              .             .
90     40            .              .               .             1
91     40            .              .              .              1
etc 

What I'm trying to do is replace breast = 0 for each control, or colon=
0 for each control, so that my data would look like this:

id    groupid     breast    colon    prostate  control
1        1              1            .              .             .
2        1              0            .               .             1
3        1              0             .              .             1
4        1              0            .               .             1
.
.
.
89     40             .             1              .             .
90     40            .              0               .             1
91     40            .              0              .              1
etc 

I can't seem to get the right combination of gen/replace/bys commands.
Can anyone help?

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