Announcement

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

  • merge, joinby, or... nothing?

    I use Stata 13.1 on a Mac and have obtained data from the National Patient Registry in Denmark, which means that the data come in multiple datasets. Each observation has a recordid which is unique to the hospital contact, i.e. if you were admitted to hospital all the tests that you were exposed to during the admission would belong to that one contact. Only one of the tables also include a personid uniquely identifying each person in the dataset.
    Tabel Contents Examples
    Adm Administrative information Date of admission, discharge, primary diagnosis, hospital department, and personid
    Sur Surgical procedures Date of surgery, surgical procedures, type of procedure, additional procedures, and hospital department
    Dit Diagnostic procedures and treatment Diagnostic tests, diagnostic procedures, type of procedure, additional procedures, and hospital department
    Vit Vital status Date of birth, vital status of the person
    Dia Diagnosis for contact Temporary (or permanent) diagnosis, type of diagnosis, additional diagnoses, and hospital department
    I believe the format of the data is long, i.e. each participant can be registered at several occasions, with each occasion constituting one observation.
    Now, my dependent variables are the diagnoses and survival, and independent variables are the diagnostic and surgical procedures that each individual was exposed to. So, in order to be able to conduct the regression analyses, I really need data to be in one file. But the only common variable is recordid, which is not unique. And according to the Stata Manual,
    First, if you think you need to perform an m:m merge, then we suspect you are wrong.
    And I understand why. But it is not completely clear to me, whether joinby has the same unnattractive features (being dependent on current sort order and potentially ruining my data). I have tried to use joinby (see below), but I am not sure, if it did something different than the m:m merge would do.

    joinby recordid using "filename", unmatched(using)

    Finally: My question is, if I can use joinby as above? Or if I should try to reshape data to be wide to obtain unique ids and then merge 1:1? Or perhaps some other solution that I have not considered?

  • #2
    Welcome to Statalist, AnneKirstine! Unfortunately you've posted in the wrong forum. This one is for making test posts. Post in the General Forum

    I have to say that I can't follow your questio easily. Read FAQ 12. You are more likely to get an answer in the General Forum if instead of describing the problem in words, you show an extract of data with code and Stata results which illustrate the problem. Show all data extracts, code, and Stata results between CODE delimiters, described in FAQ 12.
    Steve Samuels
    Statistical Consulting
    [email protected]

    Stata 14.2

    Comment


    • #3
      Dear Steve,

      Thank you very much! I thought, I had to post it here first and then move it to the general forum. But apparently that was not the case, so I copied the post manually and have already received very good feed-back! I am sincerely amazed that so many people are so kind and willing to provide feed-back to this problem that I have struggled with for so long! Now it seems that I may either find a solution, or at least know that there is none, which is a great relief either way
      I have also tried deleting the post from this sub-forum, but I could not? I don't know if it is not possible, or if I just couldn't figure it out.

      Kind regards,
      Anne-Kirstine

      Comment


      • #4
        No need to delete a post here, Anne-Kirstine. I've left mistakes in many, which I had to change when I moved them to the General Forum. To avoid misunderstanding, I try to preface the topics of my posts here with "Test Post".

        Steve Samuels
        Statistical Consulting
        [email protected]

        Stata 14.2

        Comment


        • #5
          Ok. That is a good idea - I'll do that.

          Comment

          Working...
          X