Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: st: Coding for multiple visits data


From   Tasha Amin <tamin_wh@hotmail.com>
To   Stata list <statalist@hsphsun2.harvard.edu>
Subject   RE: st: Coding for multiple visits data
Date   Fri, 8 Apr 2011 21:33:55 -0400

Sarah and Joerg, you're both right----I mistyped what I wanted the data to look like, even though I had checked before I sent. 
SO sorry. Yes, ID 1 should change at visit 6, not visit 5 (see corrected version below, in case someone else is in a similar situation and needs a solution). 
Thanks for your suggestions. Will try both of them and hoping something works. So sorry again for the confusion. 

Data 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 1 switching case only when 2 successive visits have RNA=0, ie at visit 6):
ID visit RNA case
1 1 1 0
1 3 1 0
1 5 0 0
1 6 0 1
1 7 0 1

2 1 1 0
2 2 1 0
2 3 1 0
2 4 1 0
----------------------------------------
> From: sedging@ucla.edu
> To: statalist@hsphsun2.harvard.edu
> 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: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] 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: joerg.luedicke@gmail.com
>> To: statalist@hsphsun2.harvard.edu
>>
>> 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/
 		 	   		  
*
*   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   |   Site index