Announcement

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

  • rangestat giving incorrect values as i have a missing date

    I am using rangestat to generate the total experience of the surgeon prior to the surgery being done. I am also calculating the cumulative failures, revisionexperience (variable name) also using rangestat.
    Both surgeonexperience and revisionexprience are calculating the total number of cases before that date of surgery (opdate and revision date respectively)

    This works nicely for the surgeonexperience, but for the revisionexperience - as I have missing values in the revisiondate I am getting incorrect values in my revisionexperience column . The variable expected is what I expect to see in the revisionexperience variable. I note that the problem is because I have missing in revisiondate = revision i.e a failure did not occur.

    How can I address this?

    ​​​​​​​
    Using the following code:

    Code:
    //Cumulative total number of operations before that date of surgeon = expereince
    rangestat (sum) surgeonexperience = mesh, interval (opdate . -1) by(surgeonid)
    replace surgeonexperience = 0 if missing(surgeonexperience)
    
    //Cumulative total number of REVISION operations before that date of surgeon = expereince
    rangestat (sum) revisionexperience = revised, interval (revisiondate . -1) by(surgeonid)
    replace revisionexperience = 0 if missing(revisionexperience)


    This is my data:

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float(mesh surgeonid revised opdate revisiondate) double(surgeonexperience revisionexperience) str1 expected
    1 12 1 16071 16437 0 0 "0"
    1 12 0 16438     . 1 0 "1"
    1 13 1 16499 16864 0 0 "0"
    1 13 0 16532     . 1 0 "1"
    1 16 1 16563 16928 0 0 "0"
    1 15 0 16595     . 0 0 "0"
    1 16 1 18452 18818 1 1 "1"
    1 16 1 20249 20616 2 2 "2"
    end
    format %td opdate
    format %td revisiondate


  • #2
    The reason you are getting unwanted results for revisions is that you are basing your -interval()- option on the value of revisiondate. But revisiondate is often empty--which leads to a missing value result. But what your expected variable shows you really want to know is how many revisions the surgeon has done before opdate.
    Code:
    rangestat (sum) revisionexperience = revised, interval (opdate . -1) by(surgeonid)

    Comment


    • #3
      thanks for this

      Comment

      Working...
      X