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: Correction : st: : Request code simplification
From
Phil Schumm <[email protected]>
To
<[email protected]>
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 <[email protected]> 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/