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


From   Maarten Buis <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Identifying Experiment subjects that belong in both the Placebo and Experiment Groups
Date   Mon, 22 Oct 2012 12:40:49 +0200

On Mon, Oct 22, 2012 at 12:30 PM, Beatrice Benavidez 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.

What is first and what is last depends on how you sort your dataset.
You seem to think that the dataset is sorted by ID and Date, but the
line -bysort ID (Received) : ... sorts by ID and Recieved, thus
solving your problem.

-- Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index