Announcement

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

  • Do file not running after merging data

    Hi,

    On my do-file I have a line where I am using the merge command to merge some data, but not all this data matches to my original dataset. When I run this from my do file I get this error:

    Code:
    . merge m:1 date using "/Users/raulathwall/OneDrive/Dis STATA/Fama French factors.dta", assert(master) kee
    > p(master)
    after merge, not all observations from master
    (merged result left in memory)
    r(9);

  • #2
    The assert(master) option does not mean what you think it does.

    It tells the merge that you expect the result to contain only observations that were in the master dataset only - not in the using dataset, and not in both datasets.

    If you wanted to assert that all observations in the master dataset were matched, you would want assert(match using) which tells merge you expect matched observations, and perhaps some unmatched observations from the using dataset, but no unmatched observations from the master dataset.

    Comment


    • #3
      Thanks, WIlliam for the reply!

      Unfortunately, I still get the same error with this code after I run my do file

      Code:
      . merge m:1 date using "/Users/raulathwall/OneDrive/Dis STATA/Fama French factors.dta", assert(match using
      > ) keep(master)
      after merge, not all observations from using or matched
      (merged result left in memory)
      r(9);
      Not sure if I am still inserting your comments wrong, but I can show what my data matches look like:

      Code:
      rmrf    smb    hml    umd    _merge
                      Master only (1)
      .00692538    -.00324454    -.00047937    -.00093901    Matched (3)
                      Master only (1)
                      Master only (1)
      .00064637    .00016118    .00883179    -.00535942    Matched (3)
      -.00150006    .00736057    .00405952    .00154244    Matched (3)
      -.00569254    .01037706    .00674662    -.00050846    Matched (3)
      .00563847    .00608395    .00118347    .00314485    Matched (3)
      -.00480307    .00921098    .00124585    .00489876    Matched (3)
                      Master only (1)
                      Master only (1)
      -.00350646    .00191657    .00016499    -.00268125    Matched (3)
      -.00088683    .00453016    .00836979    .00384547    Matched (3)
      .00518742    -.0002575    .00584304    .00213409    Matched (3)
      -.0005238    .00804235    -.00827145    -.00162865    Matched (3)
      .00760931    .00499901    -.00655676    -.00677073    Matched (3)
                      Master only (1)
                      Master only (1)
      .00632477    -.00086085    .00111089    -.01018524    Matched (3)
      -.00373963    .00311549    .00472982    -.00227939    Matched (3)
      .0021524    -.00691536    -.00386137    -.0092278    Matched (3)
      -.00755835    -.00109431    -.00173289    -.0101221    Matched (3)
      -.00354746    .0045432    -.00161216    .00165763    Matched (3)
                      Master only (1)
                      Master only (1)
      -.00318756    .00098517    -.00351733    -.00053702    Matched (3)
      .00068733    .00168931    .00576085    .00918041    Matched (3)
      .00330252    -.00398704    -.01172775    .00196196    Matched (3)
      -.01227804    .00284042    -.00500011    -.00251758    Matched (3)
      It is weekend data that is not being matched

      Comment


      • #4
        Apparently your using data does not contain observations for weekend days, so you now know that you do in fact have observations in your master data that will not have a match in your using data.

        Remove the assert option from the merge command.

        Comment

        Working...
        X