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


From   Michael Stewart <[email protected]>
To   statalist <[email protected]>
Subject   Re: Correction : st: : Request code simplification
Date   Tue, 11 Jun 2013 20:22:17 -0400

Hi ,

Thanks for the responses Sergiy and Phil. Solutions recommended by
both of you work very well and Stata is running smoothly.

Re: Phil's question:
Once I executed your code, I will keep records for whom
fcv_only==0.These records identify the patients who had any
transplant sometime after the initial clinic visit. And your code
works  very well .
I had bunch of other covariates that I could not post  due to
confidentiality issues but the crux of the problem was identifying pts
who would  get a transplant and retaining all records related to that
patient right from the initial clinic visit.This group will act as
"cases" in our  case-control study.


Re: Sergiy's Question:
My plan was to use carryforward to filling missing blanks in
type_of_visit column till I encounter any transplant episode and
subsequently use the code "bysort pat-id (visit_date):gen
x=v[1]==v[_n]"; although I never tried it (program was freezing
repeatedly).Once I got the list of patients, I created a temp file
(merged it with the master list) and  retained all their records.

Thank you very gain for your time and effort.

Sincerely,
Mike


On Tue, Jun 11, 2013 at 7:43 PM, Sergiy Radyakin <[email protected]> wrote:
> The following creates a dataset of IDs of patients who have had any transplant.
> I do not see how carryforward is necessary here, unless you are also
> interested in the date of the transplantation.
>
> keep if inlist(type_of_visit, codeforliver,codeforkidney,...)
> duplicates drop patient_id, force
> keep patient_id
>
> Best, Sergiy
>
>
> On Tue, Jun 11, 2013 at 5:28 PM, Michael Stewart
> <[email protected]> wrote:
>> Sorry for the typos  in the previous post(they showed up as I  was
>> removing any patient  identifiers from the dataset) , I am posting the
>> corrected request again
>>
>> Hi,
>> I am  working on a data set with thousands of patients( and multiple
>> records per patient) and I am trying to identify pateints with any
>> transplant(could undergo liver, kidney, intestine etc) . I was
>> wondering if we could simplify my  code as my laptop is freezing with
>> the following set of commands.
>>
>>
>> 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)
>>
>> My code :
>>
>> bysort pat-id (visit_date):carryforward type_of_visit,gen(v)
>> bysort pat-id (visit_date):gen x=v[1]==v[_n]
>> bysort pat-id (visit_date):egen z=sum(x)
>> bysort pat-id (visit_date):egen zz=count(x)
>> gen y= z< zz
>>
>>
>>
>> The dataset format is as follows.
>>
>> pat-id     visit_date     type_of_visit
>> -------------------------------------------------------
>> xxx      09/01/2003      first_clinic_visit
>> xxx      09/15/2003
>>                 .
>>                 .
>>                 .
>>                 .
>> XXX      12/12/2003
>> XXX      2/04/2004       liver_transplant
>> yyy      01/01/2004      first_clinic_visit
>> yyy      02/02/2005
>>                  .
>>                   .
>> yyy     01/03/2008      intestine_transplant
>> zzz      05/01/2010     first_clinic_visit
>> zzz     05/03/2011
>>                   .
>>                   .
>>                   .
>>                   .
>> ------------------------------------------------------------
>>
>> As always, thanks a lot for your time
>> Thank you ,
>> Yours Sincerely,
>> Mike.
>> *
>> *   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/
> *
> *   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/



-- 
Thank you ,
Yours Sincerely,
Mike.
*
*   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