Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

Re: st: Creating drugs combination


From   Nick Cox <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Creating drugs combination
Date   Fri, 14 Sep 2012 06:16:35 +0100

If I understand this correctly at least some values of your drug variables are composite strings of form similar to "a+b", "a+b+c", etc.

If so, then you can't count distinct drugs except by parsing those strings.

I would think in terms of -split-, -reshape long-, -duplicates drop- and -by id: gen ndrugs = _N-.

Nick

On 13 Sep 2012, at 16:39, Michele Santacatterina <[email protected]> wrote:

Dear StataList,

I have an issue. I am trying to create, from a HIV database, a variable containing the value of different drug combinations (name regimen) and the number of drugs (number of drugs)$

ID treatstart treatstop drug name_regimen number_of_drugs 2 24-Aug-95 14-Nov-97 ZDV ZDV +3TC 2
2       24-Aug-95       13-Feb-03       3TC
2 7-Aug-96 14-Nov-97 LOV ZDV+3TC +LOV 3 2 14-Nov-97 15-Jun-00 IDV 3TC+IDV +d4T 3
2       14-Nov-97       13-Feb-03       d4T
2 15-Jun-00 13-Feb-03 IDV 3TC+IDV +RTV 3
2       15-Jun-00       13-Feb-03       RTV

Patient 2 started ART at 24-Aug-95 with ZDV+3TC and at 7-Aug-96, LOV was added to the treatment becoming ZDV+3TC+LOV. At 14-nov-97 he finished with ZDV and LOV and he started with $

If I run the command

by infcare_ID treatstart, sort: gen n_trt = _n

for the number of drugs, i obtain at 7-Aug-96 just one drug (LOV) and not 3 as I should have (ZDV+
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index