Statalist


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

st: Replacing values within a matched study


From   "Nada Khan" <Nada.Khan@dphpc.ox.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Replacing values within a matched study
Date   Wed, 28 May 2008 12:16:51 +0100

Hi, 

I'm having trouble putting my finger on the solution to what may be a simple problem. 

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?

Thanks!
Nada



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