Announcement

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

  • Creating sub-group cohorts to analyse in a large cross-sectional population

    Hello,
    For my project I have a large dataset including including individuals over many years. To be eligible for inclusion in the dataset all included participants have a medical condition, call it x. I need to create a number of yearly sub-group populations that includes all the participants with x up to the first day of the year. E.g, for the sub-group year 2002, all the participants diagnosed (index date) with x before 01/01/2002 whilst excluding those with a diagnosis after this date or death/transfer out prior to 31/12/2002.
    I'm trying to figure out how to best create these sub-groups in stata so I can subsequently analyse their characteristics.
    Any advice is much appreciated.
    Best regards

  • #2
    Not a lot details to work on, but "inrange" and "if" could be the first step:

    Code:
    clear
    input date conx
    21910 1
    21915 1
    22280 1
    22280 1
    21910 0
    21915 0
    22280 0
    22280 0
    end
    format date %td
    
    gen include = conx == 1 & inrange(date, date("01/01/2020", "MDY"), date("12/31/2020", "MDY"))
    
    list, sep(0)

    Comment

    Working...
    X