# Re: st: Gen & replace

 From "Dr. Domenico Flotta" To statalist@hsphsun2.harvard.edu Subject Re: st: Gen & replace Date Fri, 2 Nov 2007 19:15:39 +0100

```Maybe this can help you

egen drugsum = sum(drug1+drug2+drug3+drug+4drug5) if drug3 !=0 | drug4
!=0 | drug5 !=0

where "0" is value for "missing pills", so even replace it with the
value you coded for missing pills

Actually, I have not been understanding your question, so try to be
more explcit and clear.

> Exactly, this is it, thank you a lot!
> Best regards
>
>
> On 11/2/07, n j cox <n.j.cox@durham.ac.uk> wrote:
> > I am sure that I understand this but
> >
> > drug3 != 0
> >
> > will evaluate as 1 whenever -drug3- is not 0.
> >
> > Thus you can count drugs by e.g.
> >
> > gen c345 = (drug3 != 0) + (drug4 != 0) + (drug5 != 0)
> >
> > Nick
> > n.j.cox@durham.ac.uk
> >
> >
> --------------------------------------------------------------------------------
> >
> > I want to calculate sum of missed pills on 3 out of 5 drugs (drug1,
> > drug2..drug5).
> > Main drugs are drug1 and drug2, and the combination is either:
> > drug1 + any 2 out of drug3,4,5
> > or
> > drug2 ?  any 2 out of drug3,4,5
> >
> > All of these drugs have value 0 when they were not used.
> >
> > i thought first to add them by typing
> > gen drugsum = drug1+drug2+drug3+drug+4drug5
> > I assume i will get total sum, but when i do ratio, STATA count with
> > patients with dug value 0.
> >
> > Any tips how to exclude counting patients with drug value = 0?
> >
> > *
> > *   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/
> >
>
>
> --
> AIDS Unit
> National Institute for Communicable Diseases (NICD)
> Private Bag X4, Sandringham, 2131
> Johannesburg, South Africa
> Mobile: +27 (0) 72-52 39 716
> Phone: +27 (0) 11-386 6433
> Fax (NICD): +27 (0)11 386 6453
> Fax (alternative): +27 (0)866 18 2871
> http://www.nicd.ac.za/
>
> Division of International Health (IHCAR)
> Karolinska Institutet
> www.phs.ki.se/ihcar
> *
> *   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/
>
*
*   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/
```