Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Coding for multiple visits data
From
Joerg Luedicke <[email protected]>
To
[email protected]
Subject
Re: st: Coding for multiple visits data
Date
Fri, 8 Apr 2011 21:23:38 -0400
On Fri, Apr 8, 2011 at 8:16 PM, Tasha Amin <[email protected]> wrote:
> A case is someone who has TWO successive study visits with 0 RNA. However, the way the data is currently coded means the person's entire case history is 1 or 0, instead of just at the visit when the person transitions.I'm including the data again, to indicate how ID 1 should be case=0 till visit 5 with visit 6 being case=1. That is, person 1 is a non-case till visit 6, when he changes.
> Looks like:
> ID visit RNA case
> 1 1 1 1
> 1 3 1 1
> 1 5 0 1
> 1 6 0 1
> 1 7 0 1
> 2 1 1 0
> 2 2 1 0
> 2 3 1 0
> 2 4 1 0
>
> Want it to look like:
> ID visit RNA case
> 1 1 1 0
> 1 3 1 0
> 1 5 0 1
> 1 6 0 1
> 1 7 0 1
> 2 1 1 0
> 2 2 1 0
> 2 3 1 0
> 2 4 1 0
What you write is indeed not matching your desired outcome as
indicated by your second data example. Two successive zeros in RNA
would mean that visits 6 and 7 were flagged, but not 5 as in your
example. For instance:
. clear all
. input ID visit RNA case
ID visit RNA case
1. 1 1 1 0
2. 1 3 1 0
3. 1 5 0 1
4. 1 6 0 1
5. 1 7 0 1
6. 2 1 1 0
7. 2 2 1 0
8. 2 3 1 0
9. 2 4 1 0
10. end
.
. gen case2=0
. bys ID (visit): replace case2=1 if RNA==0&RNA[_n-1]==0
(2 real changes made)
. list
+---------------------------------+
ID visit RNA case case2
---------------------------------
1. 1 1 1 0 0
2. 1 3 1 0 0
3. 1 5 0 1 0
4. 1 6 0 1 1
5. 1 7 0 1 1
---------------------------------
6. 2 1 1 0 0
7. 2 2 1 0 0
8. 2 3 1 0 0
9. 2 4 1 0 0
+---------------------------------+
However, I still do not know if that is what you want.
J.
*
* 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/