Announcement

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

  • Subtracting date

    Hi I have a question that I am struggling with: I have three variables of interest that I would like help with. I would like to create a variable that captures the time from when the patient was first transfered to discharge for Med/Surgical unit. Something like:

    transfer_datetime transfer_type unit_type
    01/15/19 03:05 transfer other
    01/17/19 01:20 discharge
    01/20/19 12:25 transfer other
    admit Med/Surg
    transfer Med/Surg
    transfer Med/surg
    discharge


    What I would like is a variable that shows the time between the first transfer and the discharge, for med/surgical unit type only (the discharge has no unit_type because it is discharge), and not for the "other". May you please assist with this?

  • #2
    The example data you provide is mangled and unusable. The code you ask for is sufficiently complex that it should be tested on a real example of your data. Please use the -dataex- command to post a small representative xample of your actual Stata data set. If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.



    When asking for help with code, always show example data. When showing example data, always use -dataex-.

    Comment

    Working...
    X