Announcement

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

  • m:1 merge | r(9) code halting do file

    Hello all,

    I have a do file with a m:1 merge merging in mutation characteristics (missense mutation change) from a public database (1: side) to the m-side of my master with observations containing study mutation data. While the code runs and I am happy with the way the merge looks although some did not match for acceptable reasons, the code halts everything after that. The do file containing this code is nested in a master do file and I am trying to find a fix for this. Would appreciate any help. It is not easy to -dataex- since this is a merge of two files. What can I do to change the code? Looked up help but I cannot fathom what I am doing wrong.


    merge m:1 mischange using ".\Rcodes\iarctp53", keepusing(dne_lofclass dneclass hotspot structural_motif) assert(match master) keep(match)

    after merge, not all observations from master or matched
    (merged result left in memory)
    r(9);

  • #2
    You asserted that your observations would either be matches (from both the master and using datasets) or from the master dataset but not found on the using dataset.

    Stata is telling you the assertion was incorrect: there were observations on the using dataset that were not found on the master dataset. That doesn't surprise me - the public dataset probably include possibilities that don't occur in your dataset.

    I think you don't want the assertion. Or else you want the assertion
    Code:
    assert(match using)
    which says that after the merge, there are no observations from the master dataset that were not matched - only observations from the using dataset that were not matched.

    Comment


    • #3
      Originally posted by William Lisowski View Post
      You asserted that your observations would either be matches (from both the master and using datasets) or from the master dataset but not found on the using dataset.

      Stata is telling you the assertion was incorrect: there were observations on the using dataset that were not found on the master dataset. That doesn't surprise me - the public dataset probably include possibilities that don't occur in your dataset.

      I think you don't want the assertion. Or else you want the assertion
      Code:
      assert(match using)
      which says that after the merge, there are no observations from the master dataset that were not matched - only observations from the using dataset that were not matched.
      I misunderstood the code. Thanks for interpreting. Unfortunately, I did have some in the master that did not match with the using and had to allow for that while having to avoid several other unmatched using from being merged.
      I ended up having to use the code below which allowed some unmatched ones while keeping all master as is with the few unmatched.

      merge m:1 mischange using ".\Rcodes\iarctp53", keepusing(dne_lofclass dneclass hotspot structural_motif)
      assert(1 3)
      gsort obs
      drop if _merge==2
      Last edited by Girish Venkataraman; 09 Dec 2022, 20:34. Reason: Poor grammar and typos corrected.

      Comment


      • #4
        merge m:1 mischange using ".\Rcodes\iarctp53", keepusing(dne_lofclass dneclass hotspot structural_motif)
        assert(1 3)
        gsort obs
        drop if _merge==2


        This makes no sense. If there are any observations with _merge == 2, the -assert( 1 3)- in your -merge- command will cause the code to break at that point, so your subsequent commands will never be reached. If _merge == 2 is a possibility, but you do not want to keep those observations, then your command should be
        Code:
        merge m:1 mischange using ".\Rcodes\iarctp53", keepusing(dne_lofclass dneclass hotspot structural_motif) keep(1 3)
        gsort obs


        Comment


        • #5
          Originally posted by Clyde Schechter View Post

          This makes no sense. If there are any observations with _merge == 2, the -assert( 1 3)- in your -merge- command will cause the code to break at that point, so your subsequent commands will never be reached. If _merge == 2 is a possibility, but you do not want to keep those observations, then your command should be
          Code:
          merge m:1 mischange using ".\Rcodes\iarctp53", keepusing(dne_lofclass dneclass hotspot structural_motif) keep(1 3)
          gsort obs
          [/FONT]
          I realized that my code did still break, Clyde Schechter. I did the change you suggested and it worked perfectly.
          Last edited by Girish Venkataraman; 10 Dec 2022, 05:21. Reason: Clerical error. keep was shifted to a new line by mistake.

          Comment

          Working...
          X