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, statalist.org is already up and running.


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

Re: st: Need Help with Datamanagement and Survival analysis


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: Need Help with Datamanagement and Survival analysis
Date   Sun, 2 Dec 2012 10:33:38 +0000

You should show code that you typed, not paraphrase it.

Most crucially, the code you show makes no reference to previous
values (or to folllowing dates).

Prakash also misses this point in his reply to you.

bysort name (date) : gen tag = type[_n-1] == "Telephone" & type == "In-patient"

Now such observations can be selected by -if tag-

by name : egen flag = total(tag)

Now such _patients_ have positive values of -flag- and can be selected
by -if flag-.

Nick

On Sun, Dec 2, 2012 at 5:41 AM, Dudekula, Anwar <dudekulaan@upmc.edu> wrote:

> In the following dataset :
>
> Telephone : Is a phone call made by the patient.
> Office Visit: is a clinicl visit
> Inpatient: is admission to hospital
>
> I am trying to find a set of patients in whom a Telephone(Type of Encounter)is followed by Inpatient(Type of Encounter) without any interspread Office Visit
>
> My stata code was keep if (Type of Encounter=="Telephone"|Type of Encounter=="Inpatient") but I got lot of observations with successive telephone calls followed by inpatien.
>
> I only want to see only those observations if a telephone is followed by Inpatient(event) or only telephone(censored) ; Is there  a stata code for it .
>
> In next step, is there any stata macro to convert that to survival dataset format if failure= havig inpatient admission after telephone call in observed timeperiod(year 2011)

>
> Pt Name  Date         Type of Encounter
> --------------------------------------
> pt x    4-Apr-11        Office Visit
> pt x    20-May-11       Telephone
> pt x    12-Jun-11       Inpatient
> pt x    15-Jun-11       Office Visit
> pt x    8-Aug-11        Inpatient
> pt y    12-Jul-11       Telephone
> pt y    13-Jul-11       Telephone
> pt y    14-Jul-11       Telephone
> pt y    15-Jul-11       Telephone
> pt y    16-Jul-11       Telephone
> pt y    17-Jul-11       Telephone
> pt y    19-Jul-11       Inpatient
> pt y    4-Aug-11        Office Visit
> pt y    4-Sep-11        Telephone
*
*   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