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 on April 23, and its replacement, is already up and running.

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

Re: Correction : st: : Request code simplification

From   Phil Schumm <>
To   <>
Subject   Re: Correction : st: : Request code simplification
Date   Tue, 11 Jun 2013 18:38:07 -0500

On Jun 11, 2013, at 4:28 PM, Michael Stewart <> wrote:
> Here the goal is find patients who has type_of_visit[1]=="first_clinic_visit" & any other type_of_visit is ""(after the records are sorted by pat_id and visit_date)

Taking this task exactly as stated:

    bys pat_id (visit_date): ///
        gen byte fcv_only = (_n==1 & type_of_visit=="first_clinic_visit") | ///
                            (_n>1 & mi(type_of_visit))
    bys pat_id (fcv_only): replace fcv_only = fcv_only[1]

where fcv_only equals 1 for those patients who meet the criteria you described and 0 otherwise.  I don't immediately see how this gets you closer to identifying "patients with any transplant," but you haven't provided enough information to suggest a solution to that problem.

-- Phil

*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index