Announcement

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

  • counting visits per patient per year

    Hi guys


    I have medical data where I need to see how many times per year each patient has seen a specific health care specialist.
    i have the dates they have seen the health care professional but how can i split this by per year ?

    thanks

  • #2
    It would have been more helpful if you showed us a small sample of your data so we could see the variable names and layout. But I'm gong to assume that you have one observation per visit, and that there are variables that identify the patients (patient_id), the specialists (specialist_id) and the date of the visit (visit_date). I am also assuming that your visit date variable is a genuine numeric Stata date variable, not a string variable that humans read as dates. If the last of these is not true, use the -date()- function to convert it.

    Code:
    gen int visit_year = yofd(visit_date)
    by patient_id specialist_id visit_year, sort: gen visit_count = _N

    Comment


    • #3
      Thank you so much for your response
      Sorry, I am new too this and not quite sure how to display confidential data.
      your assumptions are correct except for there are multiple observations per person. e.g one patient has seen this specialist 32 times over the sample period

      Comment


      • #4
        ps the sample spans over 30 years

        Comment


        • #5
          worked great! thank you

          Comment


          • #6
            Naturally you shouldn't display confidential data. But we are always happy with simple examples with invented data and the same essential structure as your problem.

            Comment

            Working...
            X