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: Correction : st: : Request code simplification


From   Phil Schumm <pschumm@uchicago.edu>
To   <statalist@hsphsun2.harvard.edu>
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 <michaelstewartresearch@gmail.com> 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:
*   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