Bookmark and Share

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   "Sarah Edgington" <[email protected]>
To   <[email protected]>
Subject   RE: st: Coding for multiple visits data
Date   Fri, 8 Apr 2011 17:29:10 -0700

.
I think some of the confusion may be coming from the fact that what you're
writing does not actually match the sample data you're showing.  In your
sample the case variable switches on visit 5, not 6.  If what you showed in
the sample data were what you actually wanted then the suggestions about
simple -replace- strategies would get you there.

Here's one way to get to what I think you want based on what you've written
in text:

	gen newcase=0
	sort id vist
	by id: replace newcase=1 if ( RNA = 0 & RNA[_n-1] = 0 ) |
newcase[_n-1] = 1

This only works if what you really want is case=1 only when two visits in a
row have RNA=0, which is how I interpret your request.  If that isn't what
you want it won't work.

-Sarah


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Tasha Amin
Sent: Friday, April 08, 2011 5:16 PM
To: Stata list
Subject: RE: st: Coding for multiple visits data

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
----------------------------------------
> Date: Fri, 8 Apr 2011 17:45:22 -0400
> Subject: Re: st: Coding for multiple visits data
> From: [email protected]
> To: [email protected]
>
> I think it is not quite clear what exactly you want to do. What are 
> the values in "case" supposed to indicate? And what is the relation 
> between "case" and "RNA"? From all I can see given the information 
> provided you would get the second set of example data by typing 
> -replace case=0 if RNA==1-. But I guess this is not what you are 
> looking for...
>
> 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/
 		 	   		  
*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index