Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Analysing an individual's data across multiple rows

    Dear All,

    I have a dataset of 45,000,000 observations each of which is a hospital admission. Many of these admission episodes belong to the same individual, who is identified by the variable named token_person_id. Some of these admission episodes will contain an operative intervention of interest which is identified by a variable named opnum (opnum != .) The date of this operative intervention of interest will be stored in a variable named opdate which is filled only for the episode in which the operation happened.
    I would like to:
    1) Identify all episodes for all individuals who have an episode with one of these operative interventions of interest, and drop all episodes from individuals who have never had one
    2) Be able to collate values across admissions for an individual (i.e. if in one admission there is a diagnosis of neurological disease and in another there is a diagnosis of kidney disease, i wish to be able to see in one row that there has been both neurological and kidney disease)
    3) Perform 2 with respect to a timeframe between opdate and admission date (admidate) (i.e. identify whether there was a diagnosis of neurological disease in any episodes in the five years before the operation)

    Example data
    token_person_id opnum opdate admidate neuro ckd
    1 . . 05nov2017 1 0
    1 1 23jul2018 23jul2018 0 0
    1 . . 05jan2012 0 1
    2 1 01dec2014 01dec2014 1 0
    2 . . 12mar2012 1 0
    2 . . 10may2016 0 1
    3 . . 05dec2022 0 0
    3 . . 03jan2010 0 0
    3 . . 04apr2018 0 0
    I would appreciate any help or advice,
    Thank you!

  • #2
    There are several questions here with different answers. It would help if you had a pointed question with a sample data using -dataex-. You can read up on the help in Stata for reshape, collapse and bysort for generating variables of interest in this 'long form' data. I presume you want to do this in Stata. Again, the methods to be employed will require tailoring for RAM/memory issues with as many observations. Other folks on this forum are much more conversant on these aspects than I am to answer this. Do read up the Q&A and rules in this forum so you will get a sense of how to best get a response. You can even search on this forum itself for those terms and you will get most of the answers/code so you can configure them for your needs.

    Comment

    Working...
    X