Announcement

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

  • Finding annual case volume

    Question:
    I would like to calculate the annual surgeon case volume for each surgeon whilst that surgeon has been in practice.
    That means taking into the first date the surgeon performed a surgery to the last date the surgeon performed the surgery. Then finding the total number of cases done during this timer period and finding the annual case volume during this time.


    here's by data

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(SurgeonID Surgery revision) str1 experience float(yearsurgery maxdate mindate practiceyears cumcases annualcasevol annualcases)
     1 1 0 "0" 14611 14611 14611         0 1         .         .
     2 1 1 "0" 14610 14610 14610         0 1         .         .
     3 1 1 "0" 14611 14611 14611         0 1         .         .
     4 1 0 "0" 15768 15768 15768         0 1         .         .
     5 1 1 "0" 16865 16865 16865         0 1         .         .
     7 1 1 "0" 17628 17628 17628         0 1         .         .
     8 1 1 "0" 18271 18271 18271         0 1         .         .
     9 1 1 "0" 16440 16440 16440         0 1         .         .
    10 1 0 "0" 18243 19372 18243 3.0931506 1   .323295   .323295
    10 1 0 "0" 18243 19372 18243 3.0931506 2  .6465899  .6465899
    10 1 1 "2" 18277 19372 18243 3.0931506 3  .9698849  .9698849
    10 1 0 "3" 19372 19372 18243 3.0931506 4   1.29318   1.29318
    12 1 1 "0" 16167 16475 16167  .8438356 1 1.1850649 1.1850649
    12 1 0 "0" 16167 16475 16167  .8438356 2 2.3701298 2.3701298
    12 1 0 "2" 16444 16475 16167  .8438356 3  3.555195  3.555195
    12 1 0 "2" 16475 16475 16167  .8438356 4 4.7402596 4.7402596
    end
    format %td yearsurgery
    format %td maxdate
    format %td mindate


    Here's my code:


    Code:
    **annual case load
    
    //Finding the last date of surgery 
    
    bys SurgeonID (yearsurgery) : egen maxdate = max(yearsurgery)
    format maxdate %td
    
    //fiNDING the minimum date of surgery
    bys SurgeonID (yearsurgery) : egen mindate = min(yearsurgery)
    format mindate %td
    
    
    //generate yearsin practice 
    gen practiceyears = (maxdate - mindate)/365
    
    //Mean Annual case volume 
    bysort SurgeonID(yearsurgery) : gen cumcases = sum(Surgery)
    bysort SurgeonID(yearsurgery) : gen annualcasevol = cumcase/practiceyears
    gen annualcases = cumcase/practiceyears   //same and as the line above

    the problem is that this gives the annual case volume for each surgical date, therefore as you can see for surgeon10
    the annualcase volume gradually increases as the number increase.

    When actually I would like the annual case volume during the time the surgeon was in practice ie for surgeon 10 between 2009 - 2013, the surgeon performed 4 operations therefore the annual case volume would be 1surgery/year (4cases/4years)

  • #2
    Change
    Code:
    bysort SurgeonID(yearsurgery) : gen cumcases = sum(Surgery)
    to

    Code:
    bysort SurgeonID(yearsurgery) : egen cumcases = total(Surgery)

    Comment

    Working...
    X