Statalist


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

Re: st: help with bys


From   "Austin Nichols" <austinnichols@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: help with bys
Date   Thu, 28 Aug 2008 16:06:44 -0400

You might try
egen nvisits = sum(visit>=0 &visit<999), by(studyid)
or am I misunderstanding the desideratum?

On Thu, Aug 28, 2008 at 1:01 PM, Ziad El-Khatib <ziad.khatib@gmail.com> wrote:
> Hi!
> I am dealing with cohort data for patients followed over different
> visits, before starting treatment (coded -1) then on different time
> points coded as 0, 2, 4, 8, 12, 20, 24, 36, 52, 78 and 104, also
> number 999 will be used if it was an unexpected visit to clinic.
>
> Not all patients came to all visits, so I am using -bys- command
> (pasted below) to calculate total number of visits, excluding codes -1
> and 999.
> The command below is still calculating all visits by living . value if
> visit=-1 or visit=999
>
> bys studyid: gen nvisits = _N if visit>=0 &visit<999
>
>
> Any tips?
> Thank you and best regards
> ziad
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index