Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

Re: st: Creating drugs combination

From   Nick Cox <>
To   "" <>
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-.


On 13 Sep 2012, at 16:39, Michele Santacatterina <> 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:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index