Announcement

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

  • Repeated measures data - how to create a new var with information from any of the records within patient groups

    I have data that is repeat patient encounters to the ER and each record has some information on comorbid conditions or missing in others. I want to create a variable that notes if a comorbidity is present in any of the records for each patient and attach it to the index record for each patient. Any advice?

    Example Data:
    Patient ID Comorbidity1 Comorbidity2 Comorbidity3 Visit#
    1234 1 0 0 1
    1234 0 0 0 2
    1234 0 1 0 3

    1111 0 0 0 1
    1111 1 0 1 2


    Ideally, I'd want a set that is only the first record for each patient, but includes whether they ever had a comorbid condition listed in any visit

  • #2
    Ideally, I'd want a set that is only the first record for each patient, but includes whether they ever had a comorbid condition listed in any visit
    Code:
    collapse (max) Comorbidity*, by(PatientID)
    In the future, when showing data examples, please use the -dataex- command to do so. If you are running version 17, 16 or a fully updated version 15.1 or 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

    Comment

    Working...
    X