Announcement

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

  • same day procedures

    Hello team.
    Would you please help me figure out the STATA commands for this variable? I am trying to see the safety of combining two medical procedures on the same day.


    We searched the database for hospitalizations of people who underwent the first medical procedure (Code: 02L73DK ).Hospitalizations that matched the criteria were divided into two groups based on whether an additional medical procedure (code:0DJ08ZZ) was performed on the same day.
    i made two variables:

    generate time_to_first_medical_procedure=.
    foreach var of numlist 1/25 {
    replace time_to_first_medical_procedure=PRDAY`var' if I10_PR`var' == "02L73DK"
    }


    generate time_to_other_procedure=.
    foreach var of numlist 1/25 {
    replace time_to_other_procedure=PRDAY`var' if I10_PR`var' == "0DJ08ZZ"
    }


    Now, I need to get a final variable that tells me if both procedures were performed at the same day:

    generate same_day=0

    replace same_day=1 if [[[[[ time_to_first_medical_procedure = time_to_other_procedure ]]]]]



    Thanks in advance
    Last edited by Mohamad Amer Soudan; 18 Feb 2024, 01:20.

  • #2
    This task would be considerably simpler if you first -reshape- the data to a long layout. It would then be easy to sort the procedures chronologically within patient and identify those dates where both procedures occur. It is also likely that whatever else you will be doing with the data from that point on will also be simpler, or even only possible, in long layout. But on the off chance that you really will need to do something that requires wide data, you could always -reshape- back afterward.

    The code to actually implement this is somewhat finnicky and I would not attempt to write code without having good example data, posted using the -dataex- command, to develop and test it. If you would like that kind of concrete assistance, post back. Please be sure to show an example that includes some patients who do have both procedures the same day and some others who don't. And, please, -dataex- only, no substitutes.

    If you have concerns about example posting due to confidentiality, fear not. In your example, replace any actual patient identifiers by random numbers: just be sure to use the same random number when referring to the same patient, and never use the same random number for two different patients. To mask the procedure dates, pick a single random integer between say -500 and + 500 and at that same random integer to every procedure date for every patient: this preserves the chronological order of the procedures and sameness of date but obscures when the procedures actually occurred. And all you need to show in your example is the (masked) patient id, the (masked) procedure dates, and the procedure codes (as they are). This will sufficiently deidentify the data that you can post it without a problem.

    Comment


    • #3
      I found it. Here is the solution

      **** same-day procedures*****
      generate difference= time_to_endoscopy - time_to_paracentesis
      replace same_day=1 if difference==0

      Thanks for help anyway

      Comment

      Working...
      X