Note that -egen, sum()- is now documented as -egen, total()- following
the great renaming of Stata 9. -egen, sum()- will still work.
Nick
[email protected]
Austin Nichols
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 <[email protected]>
wrote:
> 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
*
* 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/