Announcement

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

  • Matching string variables across groups

    Hi all,

    Please see dataex below. I'm working on a project that is looking to find descriptive stats on physical therapy visits post surgery. The output needs to be by both Appointment Type and Finance bucket. So, as example, we'd like to know the mean and median physical therapy visits (both PTE and PTFU) for patients that have a rotator cuff repair and have Medicare as an insurance.

    The var 'Finance' is the insurance plan of the patient. The var 'x' is the episode of care (i.e. the surgery and the physical therapy visits grouped together). The var 'pt' provides a count of 1 for each physical therapy visit. The var 'Appointment_Type' is simply the type of appointment (PTE=Physical Therapy Eval; PTFU=Physical Therapy Follow-Up; and the different types of surgeries).

    As you can see in episode #4 (x=4), the patient has two different types of insurances (both Medicare and self pay). In the observations where Finance="Self Pay", I need to change those to state "Medicare". Essentially, by x (the episode of care that always starts with a surgery), I need the patients' finance information to be consistent across all observations and all observations should match the insurance type denoted in the observation on the same row as the surgery. So, in my example of x=4, the patient had a rotator cuff surgery and has Medicare as an insurance plan. All of the patient's subsequent physical therapy visits should also list Medicare.

    Any help would be much appreciated!

    Thanks, all!




    clear
    input str15 Finance float(x pt) str95 Appointment_Type
    "NH Medicare" 1 0 "Total Knee (Surgery)"
    "NH Medicare" 1 1 "PTE"
    "NH Medicare" 1 1 "PTFU"
    "NH Medicare" 1 1 "PTFU"
    "Commercial_BCBS" 2 0 "Total Hip (Surgery)"
    "Medicare" 3 0 "Total Knee (Surgery)"
    "Medicare" 4 0 "Rotator Cuff (Surgery)"
    "Medicare" 4 1 "PTE"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Self Pay" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Self Pay" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"
    "Medicare" 4 1 "PTFU"

  • #2
    Code:
    //    VERIFY THAT ALL EPISODES, AS DEFINED BY VARIABLE X, BEGIN WITH A SURGERY
    gen `c(obs_t)' obs_no = _n    // MARK THE CURRENT SORT ORDER
    by x (obs_no), sort: assert strmatch(Appointment_Type, "*(Surgery)*") & pt == 0 ///
        if _n == 1
    
    //    MAKE FINANCE CONSISTENT WITH FINANCE CLASS AT SURGERY
    by x (obs_no): replace Finance = Finance[1]
    
    //    CALCULATE MEAN AND MEDIAN PT VISITS
    by x (obs_no): egen n_pt_visits = total(pt)
    egen flag = tag(x)
    summ n_pt_visits if flag, detail

    Comment


    • #3
      Thanks, Clyde! Always a huge help!

      Comment

      Working...
      X