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: Identifying Experiment subjects that belong in both the Placebo and Experiment Groups


From   Nick Cox <[email protected]>
To   [email protected]
Subject   Re: st: Identifying Experiment subjects that belong in both the Placebo and Experiment Groups
Date   Mon, 22 Oct 2012 12:13:50 +0100

I suggest that you read the FAQ you were referred to, which discusses
precisely this point and explains how careful -sort-ing solves the
problem.

Nick

On Mon, Oct 22, 2012 at 11:30 AM, Beatrice Benavidez
<[email protected]> wrote:
> Thank you for your reply. But what if my dataset is structured like below:
>
> Date          ID          Received
> 18/1           3            Treatment
> 19/1           3            Placebo
> 20/1           3            Treatment
> 18/1           4            Placebo
> 18/1           4            Treatment
> 18/1           4            Placebo
> 18/1           4            Treatment
>
> The particular ID's first and last observation may be the same but the
> in-betweens are different.
>
> The line "bysort ID (Received) : gen bad = Received[1] !=
> Received[_N]" may not work as [1] and [_N] only deals with first and
> last respectively.
>
> How would I run this where the number of date/treatment occurrences
> differs from one ID to another? How do I take into account if the
> Received observation is different from one occurrence to the next and
> not just from the first and last occurrence.
>
> Thank you.
>
> Kind regards,
>
>
> Beatrice
> ------------------------------
> Date: Sun, 21 Oct 2012 12:44:33 +0100
> From: Nick Cox <[email protected]>
> Subject: Re: st: Identifying Experiment subjects that belong in both
> the Placebo and Experiment Groups
>
> This is an FAQ. See
>
> How do I list observations in a group that differ on a variable?
> http://www.stata.com/support/faqs/data-management/listing-observations-in-group/
>
> bysort ID (Received) : gen bad = Received[1] != Received[_N]
>
> Nick
>
> On Sun, Oct 21, 2012 at 12:38 PM, Beatrice Benavidez
> <[email protected]> wrote:
>
>> I have a dataset like below but for thousands of subjects (IDs).
>>
>> However, in my experiment a particular subject may have received both
>> the treatment and placebo at the same or different dates (such as
>> person of ID 2 and ID 1 respectively). This occurrence would then
>> invalidate the experiment. I would then like to find a way to identify
>> and flag those subjects.
>>
>> Date          ID          Received
>> 1/1             1           Treatment
>> 1/1             2           Treatment
>> 1/1             2            Placebo
>> 17/1           1            Placebo
>> 18/1           3            Treatment
>>
>> I know I'd have to do bysort ID: gen flag = 1 if ...
> *
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index