[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
Tom Trikalinos <ttrikalin@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: RE: Complex Medical Data |

Date |
Sun, 15 Feb 2009 18:55:07 -0500 |

Pete, sorry for being cryptic. Eva finished the job for me. Thanks to Eva. TAT On Sun, Feb 15, 2009 at 8:46 AM, TA Stat <tastat@gmail.com> wrote: > Thanks > > Pete > > On Sun, Feb 15, 2009 at 5:32 PM, Eva Poen <eva.poen@gmail.com> wrote: >> TA, >> >> -reshape- does work for you. You simply need to fiddle a bit with the >> id variable. >> See here: >> >> egen namevisit = group(name visit) >> bys name visit (drug) : gen drugID = _n >> >> reshape wide drug, i(namevisit) j(drugID) >> gen str drug = drug1 + " " + drug2 + " " + drug3 + " " + drug4 >> gen GMMT = 0 >> >> replace GMMT = 1 if strpos(drug,"A") > 0 & strpos(drug,"C") > 0 >> replace GMMT = 1 if strpos(drug,"A") > 0 & strpos(drug,"D") > 0 >> replace GMMT = 1 if strpos(drug,"B") > 0 & strpos(drug,"C") > 0 >> replace GMMT = 1 if strpos(drug,"A") > 0 & strpos(drug,"B") > 0 & >> strpos(drug,"A4") == 0 & strpos(drug,"B3") == 0 >> replace GMMT = 1 if strpos(drug,"A") > 0 & strpos(drug,"B") > 0 & >> strpos(drug,"C") > 0 >> >> And the result is >> >> . list name visit drug GMMT >> >> +-----------------------------------+ >> | name visit drug GMMT | >> |-----------------------------------| >> 1. | Jen 1 B3 C3 D4 1 | >> 2. | Jen 2 A4 B3 C3 D4 1 | >> 3. | Jen 3 A4 B3 0 | >> 4. | Jen 4 A4 B3 C4 1 | >> 5. | John 1 A1 B1 C1 1 | >> |-----------------------------------| >> 6. | John 2 A1 B1 1 | >> 7. | John 3 C1 D1 0 | >> 8. | John 4 B2 C2 D1 1 | >> +-----------------------------------+ >> >> HTH, >> Eva >> >> >> >> 2009/2/15 TA Stat <tastat@gmail.com>: >>> If reshape wide is used, that means "visit" is ignored. However, but >>> both visit and drug are important in this case. Look at each clinic >>> visit of John, he received GMMT at visit 1, visit 2 and visit 3, but >>> not visit 4. GMMT can't be determined by one drug, but it is a >>> combination of some drugs. In other words, I want to conclude that at >>> each visit, each patient received GMMT or not. >>> >>> I can do Table 2 to Table 3, but not Table 1 to Table 2. >>> >>> TA >>> >>> >>> On Sun, Feb 15, 2009 at 4:01 AM, Tom Trikalinos <ttrikalin@gmail.com> wrote: >>>> TA, see >>>> >>>> help reshape wide >>>> >>>> in reshaping, j will be your drug >>>> >>>> hth, >>>> >>>> TAT >>>> >>>> >>>> On Sat, Feb 14, 2009 at 12:22 AM, TA Stat <tastat@gmail.com> wrote: >>>>> For example, from table 1 to table 2, create a variable name "GMMT" >>>>> with the conditions explain earlier. John received GMMT for visit 1, >>>>> visit 2, visit 4, but not visit 3. Jen received GMMT at visit 1, >>>>> visit 2, visit 4, but not visit 3. >>>>> >>>>> Although at visit 4 for Jen, a combination of A4 and B3 is not GMMT, >>>>> but she also received C4. So she received GMMT. At visit 3 for John, >>>>> he received C1 and D1 (any combination of drug from Class C and Class >>>>> D), so he received GMMT. >>>>> >>>>> I want to know how to get Table 2 from Table 1. >>>>> >>>>> *************************************************************************************** >>>>> >>>>> Table 1 >>>>> >>>>> Name Visit Drug >>>>> >>>>> John 1 A1 >>>>> John 1 B1 >>>>> John 1 C1 >>>>> John 2 A1 >>>>> John 2 B1 >>>>> John 3 C1 >>>>> John 3 D1 >>>>> John 4 B2 >>>>> John 4 C2 >>>>> John 4 D1 >>>>> Jen 1 B3 >>>>> Jen 1 C3 >>>>> Jen 1 D4 >>>>> Jen 2 A4 >>>>> Jen 2 B3 >>>>> Jen 2 C3 >>>>> Jen 2 D4 >>>>> Jen 3 A4 >>>>> Jen 3 B3 >>>>> Jen 4 A4 >>>>> Jen 4 B3 >>>>> Jen 4 C4 >>>>> >>>>> *************************************************************************************** >>>>> >>>>> Table 2 >>>>> >>>>> Name Visit Drug GMMT (Y=Yes, N=No) >>>>> >>>>> John 1 A1 Y >>>>> John 1 B1 Y >>>>> John 1 C1 Y >>>>> John 2 A1 Y >>>>> John 2 B1 Y >>>>> John 3 C1 N >>>>> John 3 D1 N >>>>> John 4 B2 Y >>>>> John 4 C2 Y >>>>> John 4 D1 Y >>>>> Jen 1 B3 Y >>>>> Jen 1 C3 Y >>>>> Jen 1 D4 Y >>>>> Jen 2 A4 Y >>>>> Jen 2 B3 Y >>>>> Jen 2 C3 Y >>>>> Jen 2 D4 Y >>>>> Jen 3 A4 N >>>>> Jen 3 B3 N >>>>> Jen 4 A4 Y >>>>> Jen 4 B3 Y >>>>> Jen 4 C4 Y >>>>> >>>>> >>>>> *************************************************************************************** >>>>> >>>>> Table 3 >>>>> >>>>> Name Visit Drug GMMT (Y=Yes, N=No) >>>>> >>>>> John 1 A1 Y >>>>> John 2 A1 Y >>>>> John 3 C1 N >>>>> John 4 B2 Y >>>>> Jen 1 B3 Y >>>>> Jen 2 A4 Y >>>>> Jen 3 A4 N >>>>> Jen 4 A4 Y >>>>> >>>>> >>>>> On Sat, Feb 14, 2009 at 2:29 AM, Nick Cox <n.j.cox@durham.ac.uk> wrote: >>>>>> <> >>>>>> >>>>>> An example of data would help make this clearer. >>>>>> >>>>>> Nick >>>>>> n.j.cox@durham.ac.uk >>>>>> >>>>>> TA Stat >>>>>> >>>>>> I have data arranged in the format that each row represents one drug >>>>>> for clinic visit. So, one patient may have more than one drug (row) >>>>>> for each visit. Each patient also have several clinic visits. >>>>>> >>>>>> There are 4 classes of drugs, called Class A, Class B, Class C and >>>>>> Class D. Class A has four drugs, called A1, A2, A3 and A4. Class B has >>>>>> 3 drugs, called B1, B2, B3. so as Class C and Class D (as presented >>>>>> below). Some combination of drugs is called GMMT, other is not. I >>>>>> would like to find if each patient has received GMMT at each clinic >>>>>> visit or not. Basically, I want to identify whether patient receive >>>>>> GMMT for each visit or not. >>>>>> >>>>>> Class A: A1, A2, A3, A4 >>>>>> >>>>>> Class B: B1, B2, B3 >>>>>> >>>>>> Class C: C1, C2, C3 >>>>>> >>>>>> Class D: D1, D2, D3, D4 >>>>>> >>>>>> a combination of drug is called GMMT if >>>>>> >>>>>> Class A and Class B >>>>>> >>>>>> Class A and Class C >>>>>> >>>>>> Class A and Class D >>>>>> >>>>>> Class B and Class C >>>>>> >>>>>> Class A and Class B and Class C >>>>>> >>>>>> (However, there are some exception) >>>>>> >>>>>> but not for Class C and Class D >>>>>> >>>>>> but not for A4 and B3 >>>>>> >>>>>> >>>>>> * >>>>>> * For searches and help try: >>>>>> * http://www.stata.com/help.cgi?search >>>>>> * http://www.stata.com/support/statalist/faq >>>>>> * http://www.ats.ucla.edu/stat/stata/ >>>>>> >>>>> * >>>>> * For searches and help try: >>>>> * http://www.stata.com/help.cgi?search >>>>> * http://www.stata.com/support/statalist/faq >>>>> * http://www.ats.ucla.edu/stat/stata/ >>>>> >>>> * >>>> * For searches and help try: >>>> * http://www.stata.com/help.cgi?search >>>> * http://www.stata.com/support/statalist/faq >>>> * http://www.ats.ucla.edu/stat/stata/ >>>> >>> * >>> * For searches and help try: >>> * http://www.stata.com/help.cgi?search >>> * http://www.stata.com/support/statalist/faq >>> * http://www.ats.ucla.edu/stat/stata/ >>> >> * >> * For searches and help try: >> * http://www.stata.com/help.cgi?search >> * http://www.stata.com/support/statalist/faq >> * http://www.ats.ucla.edu/stat/stata/ >> > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**References**:**st: Complex Medical Data***From:*TA Stat <tastat@gmail.com>

**st: RE: Complex Medical Data***From:*"Nick Cox" <n.j.cox@durham.ac.uk>

**Re: st: RE: Complex Medical Data***From:*TA Stat <tastat@gmail.com>

**Re: st: RE: Complex Medical Data***From:*Tom Trikalinos <ttrikalin@gmail.com>

**Re: st: RE: Complex Medical Data***From:*TA Stat <tastat@gmail.com>

**Re: st: RE: Complex Medical Data***From:*Eva Poen <eva.poen@gmail.com>

**Re: st: RE: Complex Medical Data***From:*TA Stat <tastat@gmail.com>

- Prev by Date:
**st: Left-justify labels for categories, using -graph hbar- ?** - Next by Date:
**st: reg3** - Previous by thread:
**Re: st: RE: Complex Medical Data** - Next by thread:
**st: Order Bar Graph Bars by the Over Variable** - Index(es):

© Copyright 1996–2022 StataCorp LLC | Terms of use | Privacy | Contact us | What's new | Site index |