Statalist


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

Re: st: help with bys


From   "Ziad El-Khatib" <Ziad.El-Khatib@ki.se>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: help with bys
Date   Thu, 28 Aug 2008 12:10:21 -0700

Hi Adrian, it worked, thank you a lot!
Best regards
ziad


On Thu, Aug 28, 2008 at 11:47 AM, kokootchke <kokootchke@hotmail.com> wrote:
> Hi Ziad,
>
> I think I had that problem a while ago. What I did was to just create another variable equal to studyid and then replace studyid with some other random studyid of your choice (not in the set of studyids you actually have) whenever visit is either -1 or 999. Then just use this temporal studyid like you do below, and get rid of the _N for those observations that have visit = -1 or 999.
>
> I guess you could also drop all observations with visit = -1 or 999, collapse the data by studyid, and then merge your collapsed data with the original dataset.
>
> Hope this helps.
> Adrian
>
>
>> Date: Thu, 28 Aug 2008 10:01:42 -0700
>> From: ziad.khatib@gmail.com
>> To: statalist@hsphsun2.harvard.edu
>> Subject: st: help with bys
>>
>> 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
>>
>> 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/
>
> _________________________________________________________________
> Be the filmmaker you always wanted to be—learn how to burn a DVD with Windows(R).
> http://clk.atdmt.com/MRT/go/108588797/direct/01/
> *
> *   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/
>

*
*   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